尝试使用SMTP将我的EC2实例中的电子邮件发送到SES时出现问题。由于某种原因,我遇到了偶发的超时问题,无法再联系SMTP主机。重要的是要注意,通过SES发送的时间可能达到75%。

我将从一些细节开始。我的SES帐户大部分时间都在工作。发件人的电子邮件已经过验证,我的限制已提高到每天10k(每天5电子邮件)。我的印象是,如果这与我的限制有关,我将收到特定于限制的错误。对于我的SMTP配置,我使用的是带TLS的posfix。我在官方的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名称,带有A记录的指向多个AZ中的接口(interface)。
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发送电子邮件”请求表,但是由于我使用的是Amazon的服务而不是第三方,所以对我来说这似乎很愚蠢。到目前为止,填写表格后,我还没有从亚马逊收到任何回音。

有人有什么想法吗?提前致谢。

最佳答案

因此,显然EC2具有其自身的局限性。我(错误地)假设拥有对SES的生产访问权也将意味着从EC2放宽SMTP限制,但是由于它们是两个完全独立的产品,我想并非如此。

但是正如我在帖子的最后一段中所述,您可以Request to Remove Email Sending Limitations来提高这些限制。我做到了,问题停止了(他们花了大约5个小时才取消了限制)。

更新资料

EC2限制在Connecting to the Amazon SES SMTP Endpoint中记录,并实际上限制在端口25,因此,替代的直接解决方案是仅使用端口587(不幸的是,几个官方SES示例确实使用端口25):



请注意,这可能也有些过时,就AWS Management ConsoleAmazon SES SMTP Issues节而言,它们仅指的是更常见的备用端口465和587:

关于amazon-web-services - Amazon EC2/SES SMTP超时,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11194080/

10-11 11:04