尝试使用 SMTP 从我的 EC2 实例向 SES 发送电子邮件时遇到问题。出于某种原因,我遇到了零星的超时问题,我无法再联系 SMTP 主机。需要注意的是,通过 SES 发送可能有 75% 的时间有效。
我将从一些细节开始。我的 SES 帐户大部分时间都在工作。发件人电子邮件已通过验证,我的限制已增加到 10k/天,5 封电子邮件/秒。我的印象是,如果这与我的限制有关,我会收到一个特定于限制的错误。对于我的 SMTP 配置,我使用的是 posfix w/TLS。我在官方 AWS SES 论坛上发布了一个非常相似的帖子,但还没有取得任何成功。该帖子的信息位于该帖子的底部。
这是今天早上失败的一个例子。我在下面运行的所有命令都是从我尝试从中发送邮件的 EC2 实例运行的。抱歉这篇小说大小的帖子,我只是想确保我包含所有内容。
我发送给自己的电子邮件没有送达:
Jun 25 06:16:36 intranet01 postfix/smtp18832: 9E00C230DA: to=<myemailaddress>, relay=none, delay=150, delays=0.02/0.01/150/0, dsn=4.4.1, status=deferred (connect to email-smtp.us-east-1.amazonaws.comhttp://107.22.187.122:25: Connection timed out)
当我看到失败时,我尝试通过端口 25 连接到电子邮件主机。我无法连接:
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.28.151...
^C
几分钟后,我的延期邮件终于通过了:
Jun 25 06:23:14 intranet01 postfix/smtp18861: 9E00C230DA: to=<myemailaddress>, relay=email-smtp.us-east-1.amazonaws.comhttp://184.73.218.23:25, delay=548, delays=548/0.02/0.21/0.36, dsn=2.0.0, status=sent (250 Ok 0000013823cf7441-83710873-e946-4c80-8a54-0dd72bae6f30-000000)
Jun 25 06:23:14 intranet01 postfix/qmgr3972: 9E00C230DA: removed
现在我可以连接到端口 25:
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.152.208...
Connected to email-smtp.us-east-1.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-222567251
^]
为了好玩,我决定查看 SES 主机端点。原来它只是一个 ELB cname,其中 A 记录指向多个 AZ 中的接口。
root@intranet01 sbin# dig email-smtp.us-east-1.amazonaws.com
; <<>> DiG 9.7.3-P3-RedHat-9.7.3-8.P3.17.amzn1 <<>> email-smtp.us-east-1.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8592
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;email-smtp.us-east-1.amazonaws.com. IN A
;; ANSWER SECTION:
email-smtp.us-east-1.amazonaws.com. 54 IN CNAME ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com.
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 174.129.200.82
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 184.73.219.75
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 107.20.152.208
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 107.20.160.81
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 107.20.203.50
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 107.22.229.233
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 174.129.6.189
ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com. 60 IN A 174.129.28.151
我尝试发送另一条消息,但失败了。这次我遍历了 SES cname 返回的每个 A 记录地址。我无法连接到其中任何一个。在此期间,我还尝试从我的本地机器(不是我的 EC2 实例)进行连接,它工作得很好。
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.28.151...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.6.189...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.22.229.233...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.203.50...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.160.81...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.152.208...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 184.73.219.75...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.200.82...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.28.151...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.6.189...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.22.229.233...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.203.50...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.179.13...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 107.20.160.81...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 184.73.219.75...
^C
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.200.82...
^C
等了大约 30 秒后,我再次尝试,这次成功了。
root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 174.129.28.151...
Connected to email-smtp.us-east-1.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-222567251
^C^[
^]
telnet>
正如我之前所说,我在 AWS SES 论坛上发布了一个非常相似的帖子。该帖子可以在下面找到。
https://forums.aws.amazon.com/thread.jspa?threadID=97736&tstart=0
此外,似乎我并不孤单,因为我在 SES 论坛上发现了这个其他帖子,看起来像同样的问题。
https://forums.aws.amazon.com/thread.jspa?threadID=91260&tstart=0
我认为可能存在某种 EC2 SMTP 限制,所以我填写了“从 EC2 发送电子邮件”请求表,但对我来说这似乎很愚蠢,因为我使用的是亚马逊的服务,而不是第 3 方。到目前为止,我在填写表格后还没有收到亚马逊的任何回复。
有没有人有任何想法?提前致谢。