所以我已经设置了一个 Ubuntu 服务器并想使用 postfix 来通过 php 发送邮件。
服务器主机:example.com
当服务器发送电子邮件至[电子邮件受保护],我收到错误。如果发送到任何其他地址([电子邮件受保护]),效果很好。
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = localhost
inet_protocols = all
mailbox_size_limit = 0
mydestination = example.com, localhost.localdomain, , localhost
myhostname = example.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
当我通过 php 向 example.com 地址发送邮件时,出现以下错误:
exception 'Zend\Mail\Protocol\Exception\RuntimeException' with message '5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table
当我通过 php 向 AnyOtherDomain.com 发送邮件时,没有错误:
example.com 的实际邮件由第三方服务器处理。所有 SPF / DKIM 记录均已到位,因此只要发送到第三方域,发送就可以正常工作。
显然这是一个设置,我仍在努力弄清楚。
编辑:
深入研究邮件日志我注意到这一点:
Apr 6 13:37:57 somename postfix/local[25416]: 3625CE2EB7: to=<[email protected]>, relay=local, delay=0.03, delays=0.02/0.01/0/0.01, dsn=5.1.1, status=undeliverable (unknown user: "support")
Apr 6 13:42:29 xxxxx postfix/smtpd[25501]: connect from localhost[127.0.0.1]
Apr 6 13:42:29 xxxxx postfix/smtpd[25501]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<localhost>
Apr 6 13:42:29 xxxxx postfix/smtpd[25501]: disconnect from localhost[127.0.0.1]
所以我相信服务器正在尝试发送给用户而不是电子邮件地址......
答案1
这不起作用的原因是因为我设置了:
MyDomains 将包含 example.com
来自手动的
mydestination 参数指定该机器将在本地传送哪些域,而不是转发到另一台机器。默认为机器本身接收邮件。
罪魁祸首是这一行:
mydestination = example.com, localhost.localdomain, , localhost
将其更新为:
localhost.localdomain, localhost
基本上,PostFix 试图处理Example.com 上的所有邮件,而不是将其发送出去。