我正在配置 postfix 服务器来接收入站邮件。需要在一个服务器中支持两个域。但我发现我无法做到这一点。
/etc/邮件名称
a.com
后配置-n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = a.com, b.com, i-c7fiqzb6.pek1.qingcloud.com, localhost.pek1.qingcloud.com, localhost
myhostname = i-c7fiqzb6.pek1.qingcloud.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = pcre:/etc/postfix/redirect.pcre
/etc/postfix/redirect.pcre
/^.*@a\.com$/ acom
/^.*@b\.com$/ bcom
/etc/别名
postmaster: root
acom: "| commandA"
bcom: "| commandB"
发往 a.com 的邮件可以投递给 commandA。
但是发往 b.com 的邮件也会投递给 commandA:
Sep 18 02:09:11 i-bplqojpl postfix/local[27458]: 2AB8A22CB6: to=<[email protected]>, orig_to=<[email protected]>, relay=local, delay=2, delays=1.1/0/0/0.94, dsn=2.0.0, status=sent (delivered to command: commandA)
但是我发现当我将 /etc/mailname 更改为“b.com”时,每封邮件都会被投递到 commandB,Postfix 只支持一个域?
答案1
我已解决!
原因就像@TimHaegele 所说的:它将使用 myorigin 来匹配。
解决办法是:
更改/etc/mailname
localhost
然后将 a.com 和 b.com 从 移动mydestination
到virtual_alias_domains
一切都会安好的!