Amazon EC2/SES SMTP 超时 [英] Amazon EC2/SES SMTP Timeout

查看:66
本文介绍了Amazon EC2/SES SMTP 超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an issue when trying to send emails from my EC2 instance using SMTP to SES. For some reason I am getting sporadic timeout issues, where I can no longer contact the SMTP host. It is important to note that sending through SES works probably 75% of the time.

我将从一些细节开始.我的 SES 帐户大部分都在工作.发件人邮箱已验证,我的限制已增加到10k/天,5 封电子邮件/秒.我的印象是,如果这与我的限制有关,我会收到一个特定于限制的错误.对于我的 SMTP 配置,我使用 posfix w/TLS.我在官方 AWS SES 论坛上发布了一篇非常相似的帖子,但尚未取得任何成功.该帖子的信息位于该帖子的底部.

I will start with some details. My SES account is working most of the time. The sender email has been verified, and my limits have been increased to 10k/day, 5 emails/second. I am under the impression that I would get a limit-specific error if this was related to my limits. For my SMTP configuration, I am using posfix w/TLS. I have posted a very similar post on the official AWS SES forums, but have not had any success there yet. The information for that post is at the bottom of this post.

这是今天早上失败的一个例子.我在下面运行的所有命令都是从我试图从中发送邮件的 EC2 实例中运行的.很抱歉这篇小说大小的帖子,我只是想确保我包含了所有内容.

Here is an example of a failure from this morning. All of the commands I ran below were run from the EC2 instance that I am trying to send mail from. Sorry for the novel-sized post, I just want to make sure I include everything.

我发给自己的一封电子邮件没有送达:

An email I sent to myself was not being delivered:

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 连接到电子邮件主机.我无法连接:

And when I seen the failure I tried connecting to the email host over port 25. I could not connect:

root@intranet01 sbin# telnet email-smtp.us-east-1.amazonaws.com 25  
Trying 174.129.28.151...  
^C

几分钟后,我推迟的电子邮件终于通过了:

A few minutes later my deferred email finally went through:

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:

And now I can connect to port 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 中的接口.

For kicks, I decided to look at the SES host endpoint. It turns out it is just an ELB cname, with A records that point to interfaces in multiple AZ's.

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 实例)进行连接,并且效果很好.

I tried sending another message and it failed. This time I looped through each of the A record addresses that the SES cname returned. I could not connect to any of them. During this time I also tried connecting from my local machine (not my EC2 instance), and it worked just fine.

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 秒后,我再次尝试,这次成功了.

After waiting around 30 seconds I tried again, this time it worked.

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 论坛上发布了一篇非常相似的帖子.该帖子可以在下面找到.

As I stated earlier, I posted a very similar post on the AWS SES forum. The post can be found below.

https://forums.aws.amazon.com/thread.jspa?threadID=97736&tstart=0

另外,似乎我并不孤单,因为我在 SES 论坛上发现了另一个帖子,看起来是同样的问题.

Also, it appears that I am not alone, as I found this other post on the SES forum, looks like the same problem.

https://forums.aws.amazon.com/thread.jspa?threadID=91260&tstart=0

我认为可能存在某种 EC2 SMTP 限制,所以我填写了从 EC2 发送电子邮件"请求表,但对我来说这似乎很愚蠢,因为我使用的是亚马逊的服务,而不是第三方.到目前为止,我在填写表格后还没有收到亚马逊的任何回复.

I thought there might be some sort of EC2 SMTP limitation, so I filled out the "sending email from EC2" request form, but it seems silly to me since I am using Amazon's service, as opposed to a 3rd party. So far I have not heard anything back from Amazon after filling out the form.

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

Does anyone have any ideas? Thanks in advance.

推荐答案

显然 EC2 有它自己的限制.我认为(错误地)拥有对 SES 的生产访问权限也意味着放宽 EC2 的 SMTP 限制,但由于它们是两个完全独立的产品,我想情况并非如此.

So apparently EC2 has it's own limits. I assumed (incorrectly) that having production access to SES would also mean relaxed SMTP limitations from EC2, but as they are two completely separate products I guess that is not the case.

但正如我在帖子的最后一段所述,您可以请求删除电子邮件发送限制 以提高这些限制.我这样做了,问题就解决了(他们花了大约 5 个小时才解除我的限制).

But as I stated in the last paragraph of my post, you can Request to Remove Email Sending Limitations to have these limits raised. I did that and the problem stopped (it took them around 5 hours to get my limits removed).

EC2 限制记录在连接到 Amazon SES SMTP 端点并且实际上被限制在端口 25,所以一个替代和直接的解决方案是简单地使用端口 587 代替(有点不幸的是,几个官方 SES 示例确实使用端口 25):

The EC2 throttling is documented in Connecting to the Amazon SES SMTP Endpoint and actually constrained to port 25, so an alternative and immediate solution is simply using port 587 instead (it's a bit unfortunate that several official SES examples are using port 25 indeed):

重要

Elastic Compute Cloud (EC2) 通过端口 25 限制电子邮件流量默认.通过 SMTP 发送电子邮件时避免超时来自 EC2 的端点,使用不同的端口(587 或 2587)或填写请求删除电子邮件发送限制移除油门.

Elastic Compute Cloud (EC2) throttles email traffic over port 25 by default. To avoid timeouts when sending email through the SMTP endpoint from EC2, use a different port (587 or 2587) or fill out a Request to Remove Email Sending Limitations to remove the throttle.

请注意,在 AWS 管理控制台和部分 Amazon SES SMTP 问题 仅指更常见的替代端口 465 和 587:

Beware that this might be slightly outdated as well, insofar both the AWS Management Console and section Amazon SES SMTP Issues are referring to the more common alternative ports 465 and 587 only:

您正在通过端口 25 从 Amazon EC2 实例发送到 Amazon SES,并且您无法达到您的 Amazon SES 发送限制,或者您是接收超时 — Amazon SES EC2 强加默认发送限制在通过端口 25 发送的电子邮件上并限制出站连接,如果您试图超过这些限制.要取消这些限制,请提交请求删除电子邮件发送限制.你也可以连接通过端口 465 或端口 587 连接到 Amazon SES,这两个端口都不受限制.

You are sending to Amazon SES from an Amazon EC2 instance via port 25 and you cannot reach your Amazon SES sending limits or you are receiving time outs — Amazon SES EC2 imposes default sending limits on email sent via port 25 and throttles outbound connections if you attempt to exceed those limits. To remove these limits, submit a Request to Remove Email Sending Limitations. You can also connect to Amazon SES via port 465 or port 587, neither of which is throttled.

这篇关于Amazon EC2/SES SMTP 超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆