我是用 mailcow 自建的邮局,搭建非常方便,被各种邮箱拒收之后才发现自建邮局没那么简单,以下列出我遇到的发送给 gmail 时的问题和解决方法

为了方便描述,这里使用 example.com 作为根域名,mail.example.com 作为主机名(hostname),1.1.1.1 作为邮箱服务器 IP

1. 缺少 PTR 记录

收到的拒信消息 Error: 550 5.7.25 [1.1.1.1] The IP address sending this message does not have a 5.7.25 PTR record setup&undefined; or the corresponding forward DNS entry does not 5.7.25 point to the sending IP. As a policy&undefined; Gmail does not accept messages 5.7.25 from IPs with missing PTR records. Please visit 5.7.25 https://support.google.com/mail/answer/81126#ip-practices for more 5.7.25 information. b9-20020a170902650900b001c74707965csi1293300plk.638 - gsmtp

原因 谷歌邮箱对于 PTR 非常的严格,在 帮助文档 中明确表示必须要有 PTR 记录才能发送邮件给 gmail。且发件人 IP 地址必须与指针 (PTR) 记录中指定的主机名的 IP 地址一致。

解决方法 将发件 IP 地址设置 PTR 记录

1.1.1.1 - mail.example.com

mail.example.com 设置 A 记录到发件 IP

mail.example.com A 1.1.1.1

如果你的发件服务器是动态公网IP 或 ISP 无法设置 PTR 记录,可以使用邮件中继服务器。

2. IP信誉过低

收到的拒信消息 Error: 550 5.7.1 [1.1.1.1 18] Our system has detected that this message is likely suspicious due to the very low reputation of the sending IP address. To best protect our users from spam&undefined; the message has been blocked. Please visit https://support.google.com/mail/answer/188131 for more information. ei10-20020a17090ae54a00b002719ad11d97si1014850pjb.137 - gsmtp

原因 发件服务器的 IP 被反垃圾组织列入了禁止列表中

解决方法 可以通过 DNSBL 来查看你的 IP 是否在主流的 IP 黑名单中,如果在黑名单中则需要到对应的网站申请解除。

如果无法解除 IP 黑名单可以使用邮件中继。

3. 未经请求的邮件

收到的拒信消息 Error: 550 5.7.1 [1.1.1.1 12] Our system has detected that this message is likely unsolicited mail. To reduce the amount of spam sent to Gmail&undefined; this message has been blocked. Please visit https://support.google.com/mail/?p=UnsolicitedMessageError for more information. c6-20020a056a00248600b006bc3f09ea09si813483pfv.26 - gsmtp

原因 邮件内容被识别为垃圾邮件或是 SPF、DKIM、DMARC、ARC设置不正确

解决方法 发送内容正常的邮件,设置好 DNS 中的 SPF、DKIM、DMARC,设置不正确也会导致拒收

SPF

一般的 SPF 记录为 v=spf1 a mx ip4:1.1.1.1 -all

这表示邮箱域名对应的A记录、MX记录和IP1.1.1.1被允许发送邮件,如果使用中继服务器,可以将中继服务器的IP也加进去,比如v=spf1 a mx ip4:1.1.1.1 ip4:2.2.2.2 -all

要注意,不能将 SPF 记录设置为 v=spf1 all,虽然这样表示允许所有 IP 发送邮件,但是在 gmail 是通不过的,因为允许所有 IP 发送会被认为是垃圾邮件的大本营。

DKIM

将自建邮局中的 DKIM 信息添加到 DNS 中即可

DMARC

DMARC 用来指定接收其他邮局的来信,如果你配置了正确的 DMARC 且发送邮件给 gmail,gamil 拒收之后就会发送邮件给 DMARC 中指定的邮箱,告诉你一些信息。