Cloudflare - 無法發送電子郵件

Cloudflare - 無法發送電子郵件

設定 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 位址。那麼為什麼 google 甚至嘗試將其解析為 Gmail 用戶呢?這個問題可能有什麼問題? DNS 設定和 Postfix?

如果我向 gmail 帳戶發送電子郵件,效果很好。但對於任何其他網域,谷歌似乎只是將其退回,因為它需要 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 位址的白名單,或者您需要提供憑證。

當您的郵件被退回時,要么您沒有在中繼主機上獲得授權,要么中繼主機配置不正確。

相關內容