我想在 Ubuntu Server 14.04 LTS(仅限)上使用 Postfix 2.11 将发送到本地用户帐户的邮件转发到使用另一个 SMTP 服务器的相应邮箱。
配置:
$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = loopback-only
inet_protocols = all
mailbox_size_limit = 0
mydestination = localhost mydomain.tld, myhostname, localhost.localdomain, localhost
myhostname = myhostname
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = my-target-smtp-server
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
$ cat /etc/aliases
root: [email protected]
如果我向 root 用户发送邮件
$ echo "body"| mail -s "test" root
我在/var/log/mail.log中看到以下日志条目
Nov 6 12:40:19 myhostname postfix/pickup[1854]: BD20144EC2: uid=0 from=<root>
Nov 6 12:40:19 myhostname postfix/cleanup[1898]: BD20144EC2: message-id=<20151106114019.BD20144EC2@myhostname>
Nov 6 12:40:19 myhostname postfix/qmgr[1855]: BD20144EC2: from=<[email protected]>, size=414, nrcpt=1 (queue active)
Nov 6 12:40:19 myhostname postfix/local[1901]: BD20144EC2: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.15, delays=0.11/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "some-account")
Nov 6 12:40:19 myhostname postfix/cleanup[1898]: D21A344EC4: message-id=<20151106114019.D21A344EC4@myhostname>
Nov 6 12:40:19 myhostname postfix/bounce[1902]: BD20144EC2: sender non-delivery notification: D21A344EC4
Nov 6 12:40:19 myhostname postfix/qmgr[1855]: D21A344EC4: from=<>, size=2165, nrcpt=1 (queue active)
Nov 6 12:40:19 myhostname postfix/qmgr[1855]: BD20144EC2: removed
Nov 6 12:40:19 myhostname postfix/local[1901]: D21A344EC4: to=<[email protected]>, orig_to=<[email protected]>, relay=local, delay=0.07, delays=0.03/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "some-account")
Nov 6 12:40:19 myhostname postfix/qmgr[1855]: D21A344EC4: removed
那么出于什么原因,postfix 不会使用中继服务器来转发邮件。如果我从mydestination中删除了 'mydomain.tld' ,邮件将通过作为relayhost提供的 SMTP 服务器正确发送,但/etc/aliases中的所有信息都会被忽略:邮件被发送到[email protected]而不是some-account @mydomain.tld。
你知道问题可能是什么吗?
我很确定您应该从 mydestination 中删除“mydomain.tld”。mydestination 中的条目之间也必须有一个逗号(您已经编写了 localhost mydomain.tld)。
修改 /etc/aliases 后是否运行过“newaliases”命令?