Gmail 退回 postfix 邮件

Gmail 退回 postfix 邮件

我跟着本教程使电子邮件在我的 VPS 上运行。我在向 Gmail 发送电子邮件时遇到了问题。

我可以正常接收电子邮件,但任何发送到 Gmail 的邮件都会被退回,并显示以下消息:

我们的系统检测到此邮件可能是未经请求的邮件。为了减少发送到 Gmail 的垃圾邮件数量,我们已屏蔽此邮件。请访问 550 5.7.1 https://support.google.com/mail/answer/188131了解更多信息。qa9si13920205vdb.18 - gsmtp(回复 DATA 命令结束)

我已更新我的 PTR 记录以匹配我的 IP 地址。

之前我在 mail.log 中收到如下消息:

postfix/smtp[3160]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400c:c06::1b]:25: Connection timed out

经过一番搜索,我发现这是 IPv6 的问题,我现在已经禁用了 IPv6。我不再收到这些消息,但仍然收到退回消息。

这是我的main.cf:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_use_tls=yes
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_tls_cert_file=/etc/ssl/private/<redacted>_com/ssl-bundle.crt
smtpd_tls_key_file=/etc/ssl/private/<redacted>_com.key
smtpd_use_tls=yes
smtpd_tls_auth_only = yes
smtpd_tls_loglevel = 1

smtp_address_preference = ipv4

#Enabling SMTP for authenticated users, and handing off authentication to Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions =
      permit_sasl_authenticated,
      permit_mynetworks,
      reject_unauth_destination

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = <redacted>
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = <redacted>.com, <redacted>, localhost.<redacted>, localhost
mydestination = localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_transport = lmtp:unix:private/dovecot-lmtp

#Virtual domains, users, and aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

以下是我尝试向 Gmail 发送电子邮件时收到的日志:

Jun  5 11:27:52 <redacted> postfix/master[5118]: terminating on signal 15
Jun  5 11:27:53 <redacted> postfix/master[5326]: daemon started -- version 2.11.3, configuration /etc/postfix
Jun  5 11:28:09 <redacted> dovecot: imap-login: Login: user=<<redacted>@<redacted>.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.1.1, mpid=5346, TLS, session=<0w+B8MYXwQB/AAAB>
Jun  5 11:28:09 <redacted> postfix/submission/smtpd[5347]: connect from localhost[127.0.0.1]
Jun  5 11:28:09 <redacted> postfix/submission/smtpd[5347]: Anonymous TLS connection established from localhost[127.0.0.1]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Jun  5 11:28:09 <redacted> postfix/submission/smtpd[5347]: 9A97B6241F: client=localhost[127.0.0.1], sasl_method=LOGIN, sasl_username=<redacted>@<redacted>.com
Jun  5 11:28:09 <redacted> postfix/cleanup[5352]: 9A97B6241F: message-id=<b0845816f2924994c29eecdeaf3c66c3@<redacted>.com>
Jun  5 11:28:09 <redacted> postfix/qmgr[5335]: 9A97B6241F: from=<<redacted>@<redacted>.com>, size=1032, nrcpt=1 (queue active)
Jun  5 11:28:09 <redacted> postfix/submission/smtpd[5347]: disconnect from localhost[127.0.0.1]
Jun  5 11:28:09 <redacted> dovecot: imap(<redacted>@<redacted>.com): Disconnected: Logged out in=912 out=460
Jun  5 11:28:09 <redacted> dovecot: imap-login: Login: user=<<redacted>@<redacted>.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.1.1, mpid=5357, TLS, session=<yW2G8MYXxgB/AAAB>
Jun  5 11:28:09 <redacted> dovecot: imap(<redacted>@<redacted>.com): Disconnected: Logged out in=333 out=1227
Jun  5 11:28:09 <redacted> dovecot: imap-login: Login: user=<<redacted>@<redacted>.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.1.1, mpid=5358, TLS, session=<xPqG8MYXxwB/AAAB>
Jun  5 11:28:09 <redacted> dovecot: imap(<redacted>@<redacted>.com): Disconnected: Logged out in=90 out=861
Jun  5 11:28:10 <redacted> postfix/smtp[5354]: 9A97B6241F: to=<<redacted>@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.141.26]:25, delay=0.95, delays=0.06/0.03/0.22/0.65, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[74.125.141.26] said: 550-5.7.1 [<redacted>      12] Our system has detected that this message is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please visit 550 5.7.1 https://support.google.com/mail/answer/188131 for more information. qa9si13920205vdb.18 - gsmtp (in reply to end of DATA command))
Jun  5 11:28:10 <redacted> postfix/cleanup[5352]: 9003A62422: message-id=<20150605152810.9003A62422@<redacted>>
Jun  5 11:28:10 <redacted> postfix/qmgr[5335]: 9003A62422: from=<>, size=3474, nrcpt=1 (queue active)
Jun  5 11:28:10 <redacted> postfix/bounce[5359]: 9A97B6241F: sender non-delivery notification: 9003A62422
Jun  5 11:28:10 <redacted> postfix/qmgr[5335]: 9A97B6241F: removed
Jun  5 11:28:10 <redacted> dovecot: lmtp(5362): Connect from local
Jun  5 11:28:10 <redacted> dovecot: lmtp(5362, <redacted>@<redacted>.com): nFazJArAcVXyFAAALAfe6g: msgid=<20150605152810.9003A62422@<redacted>>: saved mail to INBOX
Jun  5 11:28:10 <redacted> postfix/lmtp[5361]: 9003A62422: to=<<redacted>@<redacted>.com>, relay=<redacted>[private/dovecot-lmtp], delay=0.06, delays=0/0.02/0.01/0.03, dsn=2.0.0, status=sent (250 2.0.0 <<redacted>@<redacted>.com> nFazJArAcVXyFAAALAfe6g Saved)
Jun  5 11:28:10 <redacted> dovecot: lmtp(5362): Disconnect from local: Successful quit
Jun  5 11:28:10 <redacted> postfix/qmgr[5335]: 9003A62422: removed

答案1

本教程很棒(我自己也跟着学过),但缺少一些重要的东西,大部分与 DNS 有关。请看这里:http://blog.codinghorror.com/so-youd-like-to-send-some-email-through-code/

我再怎么强调也不为过:您需要反向 DNS 记录 (PTR)。大多数电子邮件提供商都会丢弃没有 PTR 的主机发送的消息。先解决这个问题,如果没有 PTR,那么处理其他问题就毫无意义了。

正确的 SPF 记录本身对于传递来说并不是必需的,但它将极大地提高您的邮件不进入垃圾邮件文件夹的机会。

因此,您需要配置 DKIM。之后,将您的域名添加到公共 DNS 白名单中。

您仍然会进入一些垃圾邮件文件夹(如果我没记错的话,outlook.com 似乎不能正确支持 DKIM),但比以前少见 :)

相关内容