Postfix

後綴不適用於 user@example.com 類型使用者

  • December 6, 2015

我在 Centos 7.1 上設置了一些虛擬主機,我希望使用者喜歡user@example.com這樣我可以通過回复user@example.com而不喜歡user@localhost.localdomain

Postfix 正在與使用者喜歡user但不與user@example.com,它顯示錯誤status=bounced (User unknown in virtual alias table)

/etc/postfix/main.cf

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd   $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
local_recipient_maps = hash:/etc/postfix/relay_recipients
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 62.210.xx.xx/24, 192.168.1.0/24, 127.0.0.0/8, [::ffff:127.0.0.0]/104 [::1]/128
mynetworks_style = host
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
relay_domains =
relay_recipient_maps = hash:/etc/postfix/relay_recipients
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
virtual_alias_domains = example1.com example2.com example3.com 
virtual_alias_maps = dbm:/etc/postfix/virtual
virtual_alias_maps = hash:/etc/postfix/virtual

/etc/postfix/虛擬

example1.com example1.com
#admin@example1.com admin
admin@example1.com admin@example1.com

當我這樣做時,我會收到郵件

example1.com example1.com
admin@example1.com admin

我收到錯誤status=bounced (User unknown in virtual alias table) doing this

example1.com example1.com
admin@example1.com admin@example1.com

請提出任何可能的方法來做到這一點

謝謝

我通過創建發件人規範地圖解決了這個問題

/etc/postfix/sender_canonical
user   user@example.com

然後映射

postmap /etc/postfix/sender_canonical

然後將其添加到/etc/postfix/main.cf

sender_canonical_maps = hash:/etc/postfix/sender_canonical

現在重啟 Postfix

現在我可以發送郵件useruser@example.com

希望它也對其他人有所幫助。

創建一個 relay_recipients 映射:

/etc/postfix/relay_recipients:

user1@example.com   ok
user2@example.com   ok

當然,您可以將其映射為:

$ postmap relay_recipients

然後將地圖移動到您的 postfix 目錄並重新啟動您的服務:

$ sudo mv relay_recipients.db /etc/postfix/
$ sudo service postfix restart

來自 /etc/postfix/main.cf: /etc/postfix/main.cf:

mynetworks = 127.0.0.0/8 12.34.56.0/24
relay_domains = example.com
smtpd_relay_restrictions = permit_mynetworks reject_unauth_destination

relay_recipient_maps = hash:/etc/postfix/relay_recipients

為您的虛擬別名執行相同類型的 postmap。

創建虛擬別名文件virtual

/user@.*/          user@example.com
user@example.com   user

執行:

$ postmap virtual
$ sudo mv virtual.db /etc/postfix/
$ sudo service postfix restart

引用自:https://serverfault.com/questions/740278