# 如何更改 SMTP 身份验证方法

**URL:** https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631
**Category:** Support
**Created:** [2021年四月30日 01:37 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631 "2021-04-30T01:37:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![PierreThibault](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pierrethibault/32/218755_2.png) [@PierreThibault](https://meta.discourse.org/u/PierreThibault)
#### Post date: [2021年四月30日 01:37 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631/1 "2021-04-30T01:37:22Z")

</div>

我的 Discourse 安装无法向 SMTP 服务器发送邮件。使用 `discourse-doctor` 尝试发送邮件时出现以下错误（已移除敏感信息）：

```
Testing sending to … plain auth.
======================================== ERROR ========================================
                                    UNEXPECTED ERROR

503 AUTH command used when not advertised

====================================== SOLUTION =======================================
这不是一个常见错误。目前没有推荐的解决方案！

```

我想将认证方法从 `plain` 更改为 `login`。但看起来在 `app.yml` 中并没有关于认证方法的参数。我使用的是 DigitalOcean 提供的 Discourse 镜像。

您能帮我更改 SMTP 使用的认证方法吗？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2021年四月30日 02:07 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631/2 "2021-04-30T02:07:14Z")

</div>

你只需要添加它。搜索一下应该能找到示例。

---

<div class="post-metadata">

### Author: ![PierreThibault](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pierrethibault/32/218755_2.png) [@PierreThibault](https://meta.discourse.org/u/PierreThibault)
#### Post date: [2021年四月30日 02:28 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631/3 "2021-04-30T02:28:26Z")

</div>

好的，我添加了：

```
DISCOURSE_SMTP_AUTHENTICATION: login

```

现在它使用登录认证方法，但我仍然遇到相同的错误。

---

<div class="post-metadata">

### Author: ![PierreThibault](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pierrethibault/32/218755_2.png) [@PierreThibault](https://meta.discourse.org/u/PierreThibault)
#### Post date: [2021年四月30日 20:14 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631/4 "2021-04-30T20:14:04Z")

</div>

我对此主题做了一些调研，发现并非只有我遇到这类困难。看来 Discourse 与某些 SMTP 服务器或其特定配置存在兼容性问题。

在 StackOverflow 上，[SMTP Error \<\<: 503 AUTH command used when not advertised](https://stackoverflow.com/questions/14435781/smtp-error-503-auth-command-used-when-not-advertised) 一文中，David Spector 引用了这篇博客：[Tuning cPanel TLS for SMTP incoming email reception](http://blog.networkpresence.co/?p=8923)。

这可能是由于 Discourse 在启用 SSL 或 STARTTLS 之前就尝试进行身份验证。这是否属于安全问题？是 Discourse 需要修复的问题，还是 SMTP 配置相关的问题？目前我尚不明确。

欢迎大家分享看法。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2021年四月30日 23:48 UTC](https://meta.discourse.org/t/how-to-change-the-smtp-authentification-method/188631/5 "2021-04-30T23:48:51Z")

</div>

关于那个 TLS 问题有一些设置。邮件配置确实很复杂。Discourse 与主流邮件服务商兼容。我的建议是，如果你希望操作简单，直接使用其中一家服务商即可。
