# 发送到自定义地址的电子邮件失败："与EHLO后连接丢失"

**URL:** <https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553>\
**Category:** Support\
**Tags:** email\
**Created:** [2024年十月30日 07:12 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553 "2024-10-30T07:12:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)\
**Post date:** [2024年十月30日 07:12 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/1 "2024-10-30T07:12:32Z")

</div>

我有一个类别，其中设置了“自定义入站电子邮件地址”——[CATEGORY]@forum.tasat.org

当我直接从 Gmail 发送电子邮件到该地址时，消息会按预期处理并进入该类别。

mail-receiver 成功日志：

```plaintext
Oct 30 05:26:43 forum-mail-receiver postfix/smtpd[76028]: connect from mail-ot1-f46.google.com[209.85.210.46]
Oct 30 05:26:43 forum-mail-receiver postfix/smtpd[76028]: B5B78309A1E: client=mail-ot1-f46.google.com[209.85.210.46]
Oct 30 05:26:43 forum-mail-receiver postfix/cleanup[76035]: B5B78309A1E: message-id=<CAA0dvufnp4EsAjp9XxjjirzOvocEZn9qO1bbB2h+RhC-6GZP2w@mail.gmail.com>
Oct 30 05:26:43 forum-mail-receiver postfix/qmgr[98]: B5B78309A1E: from=<[NAME]@gmail.com>, size=3056, nrcpt=1 (queue active)
Oct 30 05:26:43 forum-mail-receiver postfix/smtpd[76028]: disconnect from mail-ot1-f46.google.com[209.85.210.46] ehlo=1 mail=1 rcpt=1 bdat=1 quit=1 commands=5
<23>Oct 30 05:26:43 receive-mail[76037]: Recipient: [CATEGORY]@forum.tasat.orgOct 30 05:26:44 forum-mail-receiver postfix/pipe[76036]: B5B78309A1E: to=<[CATEGORY]@forum.tasat.org>, relay=discourse, delay=0.57, delays=0.23/0.02/0/0.32, dsn=2.0.0, status=sent (delivered via discourse service)
Oct 30 05:26:44 forum-mail-receiver postfix/qmgr[98]: B5B78309A1E: removed

```

但是，当我从 [carrd.co](http://carrd.co) 上的登陆页面的联系表单向 [CATEGORY]@forum.tasat.org 提交内容完全相同的消息时，它没有被处理。

mail-receiver 失败日志：

```plaintext
Oct 30 06:47:20 forum-mail-receiver postfix/smtpd[76057]: connect from a69-230.smtp-out.amazonses.com[54.240.69.230]
Oct 30 06:47:20 forum-mail-receiver postfix/smtpd[76057]: lost connection after EHLO from a69-230.smtp-out.amazonses.com[54.240.69.230]
Oct 30 06:47:20 forum-mail-receiver postfix/smtpd[76057]: disconnect from a69-230.smtp-out.amazonses.com[54.240.69.230] ehlo=1 commands=1

```

显然，EHLO 命令用于“识别发送主机的域名到 SMTP”。

我不知道该怎么办。什么会导致 EHLO 失败？我需要将 SES 列入白名单吗？

---

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [2024年十月30日 16:48 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/2 "2024-10-30T16:48:49Z")

</div>

> [@ToddZ](#):
>
> 我不知道该怎么办。什么会导致 EHLO 失败？我需要将 SES 列入白名单还是其他什么……？

EHLO 可能没有失败；postfix 说发送端发送了 `EHLO` 然后断开了连接。类似这样：

```plaintext
[baron ~]$ telnet forum.tasat.org 25
Trying 64.176.213.39...
Connected to forum.tasat.org.
Escape character is '^]'.
220 ESMTP server
EHLO baron
250-forum-mail-receiver.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING
^]
telnet> quit

```

（你的日志中可能会看到一条引用我 IP 地址的类似消息）

这是 SES 端的问题。我建议监控端口 25 上进来的流量，看看是否有任何迹象表明_为什么_它会断开连接，或者检查 SES 是否有任何日志。

---

<div class="post-metadata">

**Author:** ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)\
**Post date:** [2024年十月30日 18:21 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/3 "2024-10-30T18:21:50Z")

</div>

感谢 supermathie – 我无法访问 [carrd.co](http://carrd.co) 的 SES 日志，但我有另一封失败尝试的端口 25 日志。（希望我知道如何解读。）这里有什么让你觉得奇怪的地方吗……？

> **SES 失败 - Discourse 邮件接收器日志**
>
> ```plaintext
> Oct 30 16:50:11 forum-mail-receiver postfix/anvil[76091]: statistics: max connection count 1 for (smtp:159.203.42.156) at Oct 30 16:46:35
> Oct 30 16:50:11 forum-mail-receiver postfix/anvil[76091]: statistics: max cache size 1 at Oct 30 16:46:35
> Oct 30 17:49:01 forum-mail-receiver postfix/smtpd[76093]: connect from a69-230.smtp-out.amazonses.com[54.240.69.230]
> Oct 30 17:49:01 forum-mail-receiver postfix/smtpd[76093]: lost connection after EHLO from a69-230.smtp-out.amazonses.com[54.240.69.230]
> Oct 30 17:49:01 forum-mail-receiver postfix/smtpd[76093]: disconnect from a69-230.smtp-out.amazonses.com[54.240.69.230] ehlo=1 commands=1
> root@forum:/var/discourse#
> 
> ```

> **SES 失败 - Wireshark 端口 25 日志**
>
> ```plaintext
> No.	Time	Source	Destination	Protocol	Length	Info
> 11913	85.864926	54.240.69.230	64.176.213.39	TCP	74	50903 → 25 [SYN] Seq=0 Win=26883 Len=0 MSS=1460 SACK_PERM TSval=1554444054 TSecr=0 WS=128
> 11914	85.865305	64.176.213.39	54.240.69.230	TCP	74	25 → 50903 [SYN, ACK] Seq=0 Ack=1 Win=43440 Len=0 MSS=1460 SACK_PERM TSval=958362575 TSecr=1554444054 WS=1024
> 11921	85.871994	54.240.69.230	64.176.213.39	TCP	66	50903 → 25 [ACK] Seq=1 Ack=1 Win=27008 Len=0 TSval=1554444061 TSecr=958362575
> 12239	86.221038	64.176.213.39	54.240.69.230	SMTP	84	S: 220 ESMTP server
> 12245	86.227770	54.240.69.230	64.176.213.39	TCP	66	50903 → 25 [ACK] Seq=1 Ack=19 Win=27008 Len=0 TSval=1554444417 TSecr=958362931
> 12246	86.228748	54.240.69.230	64.176.213.39	SMTP	103	C: EHLO a69-230.smtp-out.amazonses.com
> 12247	86.228791	64.176.213.39	54.240.69.230	TCP	66	25 → 50903 [ACK] Seq=19 Ack=38 Win=44032 Len=0 TSval=958362939 TSecr=1554444418
> 12248	86.228963	64.176.213.39	54.240.69.230	SMTP	220	S: 250-forum-mail-receiver.localdomain | PIPELINING | SIZE 10240000 | VRFY | ETRN | ENHANCEDSTATUSCODES | 8BITMIME | DSN | CHUNKING
> 12253	86.236796	54.240.69.230	64.176.213.39	TCP	66	50903 → 25 [ACK] Seq=38 Ack=173 Win=28032 Len=0 TSval=1554444426 TSecr=958362939
> 12254	86.237257	64.176.213.39	54.240.69.230	TCP	66	25 → 50903 [FIN, ACK] Seq=173 Ack=39 Win=44032 Len=0 TSval=958362947 TSecr=1554444426
> 12257	86.243960	54.240.69.230	64.176.213.39	TCP	66	50903 → 25 [ACK] Seq=39 Ack=174 Win=28032 Len=0 TSval=1554444433 TSecr=958362947
> 
> ```

作为对比：

[details=“Gmail 成功 - Wireshark 端口 25 日志”]

```plaintext
No.	Time	Source	Destination	Protocol	Length	Info
1173638	893.998102	162.142.125.93	64.176.213.39	TCP	74	27763 → 25 [SYN] Seq=0 Win=42340 Len=0 MSS=1460 SACK_PERM TSval=1729720003 TSecr=0 WS=1024
1173639	893.998341	64.176.213.39	162.142.125.93	TCP	74	25 → 27763 [SYN, ACK] Seq=0 Ack=1 Win=43440 Len=0 MSS=1460 SACK_PERM TSval=2319295245 TSecr=1729720003 WS=1024
1173667	894.015884	162.142.125.93	64.176.213.39	TCP	54	27763 → 25 [RST] Seq=1 Win=0 Len=0
1178853	897.638926	162.142.125.207	64.176.213.39	TCP	74	60246 → 25 [SYN] Seq=0 Win=21900 Len=0 MSS=1460 SACK_PERM TSval=1654559109 TSecr=0 WS=1024
1178855	897.639088	64.176.213.39	162.142.125.207	TCP	74	25 → 60246 [SYN, ACK] Seq=0 Ack=1 Win=43440 Len=0 MSS=1460 SACK_PERM TSval=461108143 TSecr=1654559109 WS=1024
1178884	897.656814	162.142.125.207	64.176.213.39	TCP	66	60246 → 25 [ACK] Seq=1 Ack=1 Win=22528 Len=0 TSval=1654559127 TSecr=461108143
1179106	897.805588	64.176.213.39	162.142.125.207	SMTP	84	S: 220 ESMTP server
1179134	897.823322	162.142.125.207	64.176.213.39	TCP	66	60246 → 25 [ACK] Seq=1 Ack=19 Win=22528 Len=0 TSval=1654559293 TSecr=461108310
1179139	897.825315	162.142.125.207	64.176.213.39	SMTP	86	C: EHLO www.censys.io
1179140	897.825350	64.176.213.39	162.142.125.207	TCP	66	25 → 60246 [ACK] Seq=19 Ack=21 Win=44032 Len=0 TSval=461108329 TSecr=1654559295
1179142	897.825495	64.176.213.39	162.142.125.207	SMTP	220	S: 250-forum-mail-receiver.localdomain | PIPELINING | SIZE 10240000 | VRFY | ETRN | ENHANCEDSTATUSCODES | 8BITMIME | DSN | CHUNKING
1179173	897.844902	162.142.125.207	64.176.213.39	SMTP	76	C: STARTTLS
1179174	897.845039	64.176.213.39	162.142.125.207	SMTP	108	S: 502 5.5.1 Error: command not implemented
1179207	897.865559	162.142.125.207	64.176.213.39	TCP	66	60246 → 25 [ACK] Seq=31 Ack=215 Win=22528 Len=0 TSval=1654559335 TSecr=461108349
1179208	897.865879	64.176.213.39	162.142.125.207	TCP	66	25 → 60246 [FIN, ACK] Seq=215 Ack=32 Win=44032 Len=0 TSval=461108370 TSecr=1654559335
1179237	897.883702	162.142.125.207	64.176.213.39	TCP	66	60246 → 25 [ACK] Seq=32 Ack=216 Win=22528 Len=0 TSval=1654559353 TSecr=461108370
1423203	1062.340039	2001:4860:4864:20::33	2001:19f0:1000:68ec:5400:4ff:fe92:8e2b	TCP	94	45423 → 25 [SYN] Seq=0 Win=65535 Len=0 MSS=1440 SACK_PERM TSval=980279080 TSecr=0 WS=256
1424699	1063.379486	2001:4860:4864:20::33	2001:19f0:1000:68ec:5400:4ff:fe92:8e2b	TCP	94	[TCP Retransmission] 45423 → 25 [SYN] Seq=0 Win=65535 Len=0 MSS=1440 SACK_PERM TSval=980280120 TSecr=0 WS=256
1426247	1064.403473	2001:4860:4864:20::33	2001:19f0:1000:68ec:5400:4ff:fe92:8e2b	TCP	94	[TCP Retransmission] 45423 → 25 [SYN] Seq=0 Win=65535 Len=0 MSS=1440 SACK_PERM TSval=980281144 TSecr=0 WS=256
1427782	1065.427579	2001:4860:4864:20::33	2001:19f0:1000:68ec:5400:4ff:fe92:8e2b	TCP	94	[TCP Retransmission] 45423 → 25 [SYN] Seq=0 Win=65535 Len=0 MSS=1440 SACK_PERM TSval=980282168 TSecr=0 WS=256
1429343	1066.451555	2001:4860:4864:20::33	2001:19f0:1000:68ec:5400:4ff:fe92:8e2b	TCP	94	[TCP Retransmission] 45423 → 25 [SYN] Seq=0 Win=65535 Len=0 MSS=1440 SACK_PERM TSval=980283192 TSecr=
```

---

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [2024年十月30日 18:25 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/4 "2024-10-30T18:25:23Z")

</div>

> [@ToddZ](#):
>
> ```plaintext
> 12246	86.228748	54.240.69.230	64.176.213.39	SMTP	103	C: EHLO a69-230.smtp-out.amazonses.com
> 12247	86.228791	64.176.213.39	54.240.69.230	TCP	66	25 → 50903 [ACK] Seq=19 Ack=38 Win=44032 Len=0 TSval=958362939 TSecr=1554444418
> 12248	86.228963	64.176.213.39	54.240.69.230	SMTP	220	S: 250-forum-mail-receiver.localdomain | PIPELINING | SIZE 10240000 | VRFY | ETRN | ENHANCEDSTATUSCODES | 8BITMIME | DSN | CHUNKING
> 12253	86.236796	54.240.69.230	64.176.213.39	TCP	66	50903 → 25 [FIN, ACK] Seq=38 Ack=173 Win=28032 Len=0 TSval=1554444426 TSecr=958362939
> 
> ```

SES 在数据包 12253（`FIN`）中自行关闭了连接。

至于原因，您需要咨询 AWS。

---

<div class="post-metadata">

**Author:** ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)\
**Post date:** [2024年十月31日 21:04 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/5 "2024-10-31T21:04:47Z")

</div>

非常感谢！我已经请求 [carrd.co](http://carrd.co) 支持检查日志，但他们显然位于邻近的太阳系。可能需要一段时间我才能获得更多信息。

---

<div class="post-metadata">

**Author:** ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)\
**Post date:** [2024年十一月7日 00:47 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/6 "2024-11-07T00:47:32Z")

</div>

好吧，我从 [carrd.co](http://carrd.co) 获得的支持信息不多，除了他们声称使用“机会性 TLS”，应该会回退到未加密连接。

我没有通过的那个 [邮件服务器健康检查](https://mxtoolbox.com/emailhealth) 是 SMTP 标志与反向 DNS `PTR` 记录提供的域不匹配。在 [元论坛的其他地方](https://meta.discourse.org/t/customize-direct-delivery-postfix-configuration/118759/17?u=toddz)，我找到了在 `env:` 下添加 `mail-receiver.yml` 的想法：

```plaintext
POSTCONF_smtpd_banner: forum.tasat.org ESMTP $mail_name

```

这解决了关于 SMTP 标志不匹配的标志，并且入站邮件失败从 HELO 断开改为 STARTTLS 断开。

我终于启用了 TLS，并且来自联系表的电子邮件已成功发送。

不过，随着流程现在正常工作，它也暴露了我通过 Web 表单摄取主题的整个想法中的一些缺陷。但这将是另一个话题。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2025年十月17日 06:38 UTC](https://meta.discourse.org/t/email-to-custom-address-fails-lost-connection-after-ehlo/333553/7 "2025-10-17T06:38:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
