最近公司遇到了一个客户问题,发往gmail邮箱,客户收到延迟。公司老大分析了一天终于有了答案。闲下是我做了个整理把
经验分享下。
最近客户反馈,发送给gmail.com 和binance.com 的邮件, 收到有延迟,查看海外邮件中继服务器发信日志,日志显示10:00 Google 已经接收了邮件,但是客户在邮箱是在10:04(需要等4分钟)才能刷新到这封邮件。这种现象并不是必现,在第一次给某新地址发送时大概率会出现, 后续在给这个地址发信就大概率不会出现。(实际上后来客户测试, 旧地址在隔一段时间之后还是会出现)
于是我们查看google收到邮件的原文,发现存在2个头域 Received 和 X-Received. 这2者显示的时间戳刚好有4min 的延迟.
通过Google搜索,我们从一个网站了解到:X-Received 是Google 加上去的. Received 是RFC 规范要求SMTP 协议加上去的.
该网占地址:https://emailheaders.net/gmail.htm,具体针对这两个邮件头扩展字段说明如下
Received By: The received email header denotes the information related to the last SMTP server visited by message:
The IP address of the serverThe SMTP id for the visited serverThe date and time at which message was received by SMTP server
X Received: The server or mail agent adds the X-received header field in email addresses to indicate the non-standard header information. It indicates the following information:
The IP address of the server, which received messageThe SMTP id for the serverSpecific date and time at which email was received
我们猜想是不是我们邮件中继服务器部署在新加坡, 邮件投递给了Google 新加坡的入口造成的延迟,于是 我们直连google US MX记录。 我们测试没问题, 客户过几天之后, 说还是存在问题. 查日志, 的确连接的是US 的mx。猜测失败,蛋疼。。。
继续查文档, 终于找到了原因. 是因为Google为了防范钓鱼邮件, 对邮件内容和可疑链接做了个扫描. 这个可能会 导致4min 的延迟. 这个策略会针对gmail.com 和google G suite 下的企业邮箱(客户测试的是binance.com).
google 对这个问题的官方声明 https://gsuiteupdates.googleblog.com/2017/05/early-detection-of-phishing-via-delayed-delivery.html
民间对这个问题的解决方法 https://support.google.com/mail/forum/AAAAK7un8RUymI34flRdJ8
如何在G Suite 关闭这个安全性检查 Use enhanced pre-delivery message scanning https://support.google.com/a/answer/7380368 之后和客户做了沟通, 客户知晓并理解了这个问题
https://web.sendcloud.net