新的 Discourse/Docker 安装无法发送邮件

大家好,
我想将一个长期运行的论坛从 phpBB3 迁移到 Discourse。我成功设置了 Docker,并且可以访问初始设置。但不幸的是,没有邮件发送,所以我无法完成初始化。
我进行了一些调试,但找不到原因,因此向大家寻求帮助。

我的设置如下:我设置了 apache2 作为反向代理到 Docker,这很有效。我的邮件服务器是同一台机器上的 mailcow Docker。邮件服务器经过了彻底的测试,并且每天通过 SMTP(使用 STARTTLS 和端口 587)以及 Webmail 正常工作。

我的 app.yml 中的配置如下:

  DISCOURSE_SMTP_ADDRESS: mail.example.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@example.com
  DISCOURSE_SMTP_PASSWORD: "password"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  #DISCOURSE_SMTP_DOMAIN: mail.example.com
  DISCOURSE_NOTIFICATION_EMAIL: discourse@example.com

当我运行 ./discourse-doctor 时,我得到:

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@example.com]:
Sending mail to admin@example.com. . .
Testing sending to admin@example.com using mail.example.com:587, username:discourse@example.com with plain auth.
=======================================
ERROR
=======================================
                                   UNEXPECTED ERROR

Cannot assign requested address - connect(2) for [correct ipv6]:587

=======================================
SOLUTION
=======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to https://meta.discourse.org/
(And a solution, if you find one!)

在网上找不到类似错误信息的人,我转向了这个帖子
我能够轻松地从容器外部通过 telnet 连接到邮件服务器。

我在容器内部尝试的操作:

getent hosts mail.example.com

提供了正确的 IPv6 地址。
但随后错误开始出现:

openssl s_client -connect mail.example.com:587 -starttls smtp
140124593714496:error:0200206E:system library:connect:Connection timed out:../crypto/bio/b_sock2.c:110:
140124593714496:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=110
openssl s_client -6 -connect "[correct IPv6]:587" -starttls smtp
139918557709632:error:02002063:system library:connect:Cannot assign requested address:../crypto/bio/b_sock2.c:110:
139918557709632:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=99
 openssl s_client -connect smtp.gmail.com:587 -starttls smtp

可以正常工作。
当我从容器外部尝试

openssl s_client -connect mail.example.com:587 -starttls smtp

时,它也工作正常。
我的 mailcow/postfix 日志没有任何显示……
我感到很困惑。你能帮我看看接下来该检查哪里吗?

1 个赞

请参阅新 Discourse 安装上的电子邮件故障排除

问题很可能是您的通知电子邮件地址不是您已配置为发送的标记服务器的地址。

但这并不能解释“连接超时”错误。这听起来像是一些 Docker 网络问题。

1 个赞

谢谢您的回复。我尝试在两个字段中使用相同的地址,但没有变化,错误依旧存在。
根据故障排除线程:

Discourse 日志显示什么?

Job exception: Cannot assign requested address - connect(2) for [*correct IPv6*]:587

您的电子邮件提供商日志显示什么?

没有日志条目显示从 Discourse 发送的邮件。

然后我尝试了此方法 https://www.saotn.org/test-smtp-authentication-starttls/ 来查看是否能通过 openssl 进行身份验证,它在服务器上运行正常,但在容器内运行时会产生我在第一个帖子中描述的错误。

我该如何找出是什么阻止了这里的连接?

1 个赞

太简单了。
我只需要在我的 Docker 网络中激活 IPv6,只需按照此教程的前三个步骤操作即可。

3 个赞

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