# 邮件无法使用，550-Bad HELO

**URL:** https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592
**Category:** Support
**Created:** [2019年九月26日 16:53 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592 "2019-09-26T16:53:43Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年九月26日 16:53 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/1 "2019-09-26T16:53:43Z")

</div>

我在家里的本地迷你 PC（运行 Ubuntu 16.04 LTS）上运行测试环境（当前版本为 2.4.0.beta4）。我使用出色的 [30 分钟安装指南](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) 进行了安装。该系统已配置了完全限定域名（FQDN）。通过我的 ISP 提供的邮箱，使用 SMTP 端口 587 进行明文身份验证发送邮件，这一功能已稳定运行超过一年。

我刚刚意识到，有一段时间没有收到任何电子邮件通知，例如“新版本可用”。检查 管理 \> 电子邮件 \> 已跳过 后发现，所有邮件都收到了以下错误提示：

> 550-Bad HELO: localhost.localdomain 不存在 - 请参阅 RFC 2821

回顾邮箱记录，这个问题可能始于 2.4.0.beta2 版本。但也可能是我的 ISP 在大约同一时间（2019 年 7 月底）更改了相关策略。我不确定该从何入手。这个 `localhost.localdomain` 是从哪里来的？在安装过程中，我只需要编辑 app.yml 文件，而该文件中 DISCOURSE\_HOSTNAME 设置已正确显示我的 FQDN。

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [2019年九月26日 17:07 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/2 "2019-09-26T17:07:51Z")

</div>

那个 localhost.localdomain 似乎来自您的 ISP。您介意用 Mailgun 测试一下吗？

---

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年九月26日 20:10 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/3 "2019-09-26T20:10:36Z")

</div>

我从未听说过 Mailgun。您是指 [mailgun.com](http://mailgun.com) 吗？也就是“事务性电子邮件 API 服务”？为了让您了解我的知识水平：我对 API 只有模糊的概念，但并不知道如何使用它。不过，我可以尝试通过 SMTP 将邮件发送到另一个 ISP 的不同邮箱。我明天会在这里汇报进展。

---

<div class="post-metadata">

### Author: ![jtbayly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jtbayly/32/119510_2.png) [@jtbayly](https://meta.discourse.org/u/jtbayly)
#### Post date: [2019年九月26日 20:22 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/4 "2019-09-26T20:22:30Z")

</div>

注册 Mailgun 即可获得 SMTP 凭证。我相信您只需按照注册时的指引操作即可搞定。

---

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年九月27日 19:45 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/5 "2019-09-27T19:45:26Z")

</div>

@itsbhanusharma, @jtbayly 谢谢！我刚刚成功通过 Mailgun 发送了一条测试消息。所以问题出在我 ISP 的 SMTP 服务器的新策略上。我可能会继续使用 Mailgun。

---

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年九月30日 14:25 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/6 "2019-09-30T14:25:10Z")

</div>

我做了更多研究，因为我们的生产论坛无法使用 Mailgun。

在通过 Mailgun 收到的电子邮件头部，我仍然看到：

> Received: from localhost.localdomain

HELO 是 SMTP 对话中的第一条命令（[来源](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol#SMTP_transport_example)）

它应该是类似这样的：

> HELO discourse.mydomain.tld

某些 SMTP 服务器（如 Postfix）有一个选项，可以将此信息与客户端的 IP 地址进行核对。localhost.localdomain 解析为 SMTP 服务器的 IP 地址，该名称可能存在于其 hosts 文件中。看起来各大 ISP 正在启用此功能以对抗垃圾邮件。

使用 Mailgun 时没有问题，因为 Mailgun 不执行此检查。但这仍然是一个“错误的 HELO”。

作为对比，我在同一系统上使用电子邮件客户端（Sylpheed）发送了邮件。这可以正常工作，即使是通过我的 ISP 的邮箱发送，而且它似乎使用了：

> HELO HL80L

HL80L 是我的本地网络名称。这仍然不是完全限定域名（FQDN），但至少在我的 ISP 服务器看来，它不像明显的伪造信息。

所以，这或许是需要改进的地方。但免责声明：我不是 SMTP 专家。

---

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年九月30日 15:43 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/7 "2019-09-30T15:43:21Z")

</div>

顺便说一下，我通过在 ISP 的邮箱和 NAS 之间部署一个作为中继的 MTA（基于 Postfix 的应用），让它重新运行起来了。它使用的是 HELO mydomain.tld。

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2019年十月1日 04:47 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/8 "2019-10-01T04:47:12Z")

</div>

我会检查一下在切换到 Debian 10 或升级到 Rails 6 的过程中是否出了问题。在此期间，在 `app.yml` 中设置 `DISCOURSE_SMTP_DOMAIN` 应该可以生效。我想，如果未显式设置 SMTP 域名，我们应默认使用 `DISCOURSE_HOSTNAME` 的值。🤔

---

<div class="post-metadata">

### Author: ![willemb2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/willemb2/32/91608_2.png) [@willemb2](https://meta.discourse.org/u/willemb2)
#### Post date: [2019年十月1日 14:13 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/10 "2019-10-01T14:13:48Z")

</div>

谢谢，@gerhard！我的 `app.yml` 中原本没有 `DISCOURSE_SMTP_DOMAIN`，但我深吸一口气，把它加上了，果然奏效。我现在又能使用我的 ISP 邮箱了。在接收端，我在邮件头中看到了以下内容：

> Received: from XXXXXXX.cable.dynamic.v4.ziggo.nl ([XX.XX.XX.X] helo=mydomain.tld)  
> by [smtp7.mnd.mail.iss.as9143.net](http://smtp7.mnd.mail.iss.as9143.net) with esmtpsa (TLS1.2:ECDHE\_RSA\_AES\_256\_GCM\_SHA384:256)  
> (Exim 4.90\_1)

与此同时，我了解到 RFC 2821 及其后继标准 [RFC 5321，第 4.1.4 节](https://tools.ietf.org/html/rfc5321#section-4.1.4) 均指出：

> SMTP 服务器可以验证 EHLO 命令中的域名参数是否确实与客户端的 IP 地址对应。然而，如果验证失败，服务器不得以此为由拒绝接收邮件。验证过程中获取的信息仅用于日志记录和追踪。请注意，此限制仅适用于参数与其 IP 地址的匹配；关于拒绝传入连接或邮件的更详细讨论，请参阅第 7.9 节。

但许多邮件传输代理（MTA），如 Postfix 和 Exim，似乎仍提供可选设置来执行此类验证。可能管理员们为了应对持续的垃圾邮件攻击而启用了该功能。

---

<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: [2019年十月31日 14:25 UTC](https://meta.discourse.org/t/email-stopped-working-550-bad-helo/129592/11 "2019-10-31T14:25:45Z")

</div>

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