将 ./discourse-setup 连接到本地 localhost:25 且无需认证的 SMTP 服务器时,正确的设置是什么?
我非常惊讶这竟然不是开箱即用的功能;这在大多数 Linux 安装中是默认配置。
我的服务器在本地运行 postfix;它无法从互联网访问。例如,运行 mail 命令时一切正常。我在网上找到了一些非官方指南,建议修改 /var/discourse/containers/app.yml,最终我使用以下设置成功安装并启动了:
DISCOURSE_SMTP_ADDRESS: localhost
DISCOURSE_SMTP_PORT: 25
DISCOURSE_SMTP_USER_NAME: discourse@opensouceecology.org
DISCOURSE_SMTP_PASSWORD: "none"
DISCOURSE_SMTP_AUTHENTICATION: none
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_ENABLE_START_TLS: false
请注意,如果我省略 DISCOURSE_SMTP_USER_NAME 或 DISCOURSE_SMTP_PASSWORD 变量,安装脚本会报错提示它们是必需的(这是一个 bug 吗?)。
现在,当我在 Discourse 的 Web 界面中点击“重新发送激活邮件”按钮时,日志文件(/var/discourse/shared/standalone/log/rails/production.log)中会出现以下条目:
Started PUT "/finish-installation/resend-email" for 127.0.0.1 at 2019-11-07 13:15:31 +0000
Processing by FinishInstallationController#resend_email as HTML
Parameters: {"authenticity_token"=>"SzQCvRWiqdXsBKzOjIB0X7KkvXro7Od6SdP8Qa8vvrskPeNYZNos5ORHJfyDUrHiKShZR/txM6NHuqHHCQCR1w=="}
Rendering finish_installation/resend_email.html.erb within layouts/finish_installation
Rendered finish_installation/resend_email.html.erb within layouts/finish_installation (Duration: 0.7ms | Allocations: 103)
Rendered layouts/_head.html.erb (Duration: 0.5ms | Allocations: 103)
Completed 200 OK in 98ms (Views: 3.0ms | ActiveRecord: 0.0ms | Allocations: 4763)
Rendering layouts/email_template.html.erb
Rendered layouts/email_template.html.erb (Duration: 0.5ms | Allocations: 141)
Delivered mail c4ca58ca-345e-46c4-81bc-6d0eac7afa04@discourse.opensourceecology.org (11.3ms)
Job exception: wrong authentication type none
……但我的认证类型确实是 ‘none’。无需认证的正确设置应该是什么?
编辑:另外,有人能链接到定义所有可能的 DISCOURSE_SMTP_* 变量及其所有有效值的文档吗?
编辑 2:事实证明这比应有的困难得多。我认为 ‘localhost’ 在 Docker 容器内解析为 Discourse Docker 容器本身(app),而不是运行我的 postfix SMTP 服务器的 Docker 主机。这又因 postfix 的 mynetworks 和 iptables(由 discourse-setup 脚本或其子脚本配置)而变得更加复杂。正确的配置应该是什么,才能让 Discourse 直接使用我想运行 Discourse 的那台服务器上的 SMTP 服务器,且无需 SMTP 认证?