设置 Cloudflare 后,我无法发送电子邮件。我创建了 A 记录 mail.example.com 和 MX 记录 example.com。当我接收电子邮件时,它工作正常,但当服务器发送电子邮件时,我收到错误:
to=<[email protected]>, relay=ASPMX.L.GOOGLE.COM[74.125.205.26]:25, delay=0.58, delays=0.05/0.01/0.45/0.07, dsn=5.1.1, status=bounced (host ASPMX.L.GOOGLE.COM[74.125.205.26] said: 550-5.1.1 The email account that you tried to reach does not exist.
然而,奇怪的是收件人字段甚至不包含 gmail 地址。那么为什么谷歌甚至试图将其解析为 gmail 用户?这个问题可能是什么?DNS 设置和 Postfix?
如果我向 gmail 帐户发送电子邮件,一切正常。但对于任何其他域,Google 似乎都会将其退回,因为它需要 gmail 地址。
编辑:
main.cf(编辑可以识别服务器的值):
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
disable_vrfy_command = yes
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = $myhostname, mail.example.com, localhost.example.com, localhost, $mydomain
mydomain = example.com
myhostname = mail.example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 xxx.xxx.xxx.xx
myorigin = $mydomain
readme_directory = no
recipient_delimiter = +
relayhost = myhost.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_helo_required = yes
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
master.cf:
smtp inet n - y - - smtpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - y 1000? 1 tlsmgr
rewrite unix - - y - - trivial-rewrite
bounce unix - - y - 0 bounce
defer unix - - y - 0 bounce
trace unix - - y - 0 bounce
verify unix - - y - 1 verify
flush unix n - y 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - y - - smtp
relay unix - - y - - smtp
showq unix n - y - - showq
error unix - - y - - error
retry unix - - y - - error
discard unix - - y - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}
答案1
通过此设置,relayhost = host.example.com
您可以设置非本地邮件的下一跳目的地;也就是说,您不会直接将电子邮件发送到目的地,而是指示 Postfix 将所有邮件简单地交给中继服务器(有时称为“智能主机”) 进行实际交付。
默认情况下relayhost
未设置,Postfix 将(尝试)将邮件直接发送给收件人。
通常,您的 Postfix 服务器需要获得中继主机的授权,然后该服务器才能接受您的消息。该授权通常是基于 IP 地址的白名单,或者您需要提供凭证。
当您的邮件被退回时,要么是您未获得中继主机的授权,要么是该中继主机配置不正确。