需要帮助,我在调试电子邮件配置(Infomaniak/Brevo)时被卡住了

你好!

我正在为我们的小非营利协会安装 Discourse。我选择在 Infomaniak 的 Public Cloud 上使用 Ubuntu 22.04 云实例,并将交易邮件设置为使用 Brevo,因为他们的免费套餐包含每月 300 封邮件。

在设置服务器的过程中,我遇到了一些问题,但通过文档和这里的帖子得到了很多帮助……

但是
现在我遇到了一个不知道如何继续的瓶颈。

  1. 我们的论坛可以通过 forum.aether-labs.fr 子域名访问。

  2. 我的 Brevo 账户工作正常,因为我成功地从 noreply@forum.aether-labs.fr 向 Thunderbird 发送了邮件。

  3. 但我没有收到用于验证账户的第一个管理员邮件。

所以我详细阅读了帖子 Troubleshoot email on a new Discourse install(因为是新用户,没有链接),并尝试了一些方法。

  1. 应用程序容器(似乎?)成功连接到 Brevo 的 SMTP 服务器端口。
root@server-1:/var/discourse#
root@server-1:/var/discourse# ./launcher enter app
x86_64 arch detected.
root@server-1-app:/var/www/discourse#
root@server-1-app:/var/www/discourse# openssl s_client -connect smtp-relay.sendinblue.com:587 -starttls smtp
CONNECTED(00000003)depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1depth=0 CN = *.sendinblue.com
verify return:1
---
Certificate chain
 0 s:CN = *.sendinblue.com
   i:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
 1 s:C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
   i:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
 2 s:C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
   i:C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
---
Server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Zy8vTYYMrSn40pzLbL1np7t+jpEb
ratD0fgmtozDRDWw
-----END CERTIFICATE-----
subject=CN = *.sendinblue.com

issuer=C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA

---
No client certificate CA names sent
Peer signing digest: SHA512
Peer signature type: RSA
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 5482 bytes and written 476 bytes
Verification: OK
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: FF96A2562FFDC00C5948FE7E6123CE9CD4CFB4939A4546728F60584ED2EC12EB
    Session-ID-ctx:
    Master-Key: 287A2ECAB44E3F1EB919B4AD0EF98981A05F866381485781BB46AFEA2F361E987C31E57DA1098B01F69B75679E07E430
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 6d 30 ab bf 0a 44 79 06-0a 1a 67 1a 25 b5 f8 05   m0...Dy...g.%...
    0010 - 8e 33 6c 9a db 35 cd 9e-64 d6 a3 44 59 36 d4 e1   .3l..5..d..DY6..
    0020 - 69 b2 46 6a d5 7a 22 25-c2 36 bd bc ef ca d8 bf   i.Fj.z"%.6......
    0030 - 1c e2 b5 31 4e ab 43 cf-ea a0 1a b8 39 69 cd 5c   ...1N.C.....9i.\
    0040 - 15 b5 94 17 9c 70 d0 9d-ff 7c 7f e9 3f c8 87 a2   .....p...|..?...
    0050 - d0 12 5d a2 2b 6c e3 54-aa 33 10 fa b5 08 57 9f   ..].+l.T.3....W.
    0060 - 64 ce cc 08 53 24 f1 5c-4f 6b 4c 19 f1 f8 83 be   d...S$.\OkL.....
    0070 - 97 11 17 3f 83 5f 9f 9c-16 73 86 98 c8 d6 72 a8   ...?._...s....r.
    0080 - 44 7a bd 43 e3 40 44 a5-f4 6d 7f 36 19 e4 f3 84   Dz.C.@D..m.6....
    0090 - ec 3f 0b 65 0c 53 ef 73-ef 43 19 8c 34 27 87 40   .?.e.S.s.C..4'.@
    00a0 - 7e 52 5f 6f 7a 2d e6 08-a6 fc 6f 77 a9 47 f3 fa   ~R_oz-....ow.G..
    00b0 - eb 56 ac 1d f0 42 de 45-37 22 ec 5e 13 48 09 41   .V...B.E7".^.H.A

    Start Time: 1700936536
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no
---
250 STARTTLS
^C
root@server-1-app:/var/www/discourse#
root@server-1-app:/var/www/discourse#

最后的日志是 250 STARTTLS 而不是之前帖子中指定的 250 DSN,对我这个非专家来说似乎没问题。

  1. 但是 discourse-doctor 无法发送邮件,并提示端口已关闭(我尝试过 587、2525 和 465,不使用 starttls)。
==================== 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) [contact@aether-labs.fr]: test-f2ps9wb2f@srv1.mail-tester.com
Sending mail to test-f2ps9wb2f@srv1.mail-tester.com. . .
Testing sending to test-f2ps9wb2f@srv1.mail-tester.com using smtp-relay.sendinblue.com:587, username:forum@aether-labs.fr with plain auth.
======================================== ERROR ========================================
Connection to port 587 failed.
====================================== SOLUTION =======================================
The most likely problem is that your server has outgoing SMTP traffic blocked.
If you are using a service like Mailgun or Sendgrid, try using port 2525.
=======================================================================================

所以,正如(4)所示,似乎出站 SMTP 流量没有被阻止,我不知道如何继续以及应该更改什么配置才能正确配置交易邮件。

您或许可以与您的虚拟机提供商联系,看看出站端口是否被阻止。

感谢 @pfaffman
我刚给他们发了封邮件。

但是 openssl s_client -connect smtp-relay.sendinblue.com:587 -starttls smtp 能够正常工作,而使用 smtp-relay.sendinblue.com:586 却得不到结果,这很奇怪,不是吗?我猜流量没有被阻止?我的意思是,如果能收到响应,说明数据包确实到达了 smtp-relay.sendinblue.com:587……

所以支持人员告诉我配置一切正常,并且出站端口没有被阻止。

所以我尝试通过 openssl 完全发送邮件,是的,我成功地从 Docker 容器内部给自己发送了一封邮件。

root@server-1-app:/var/www/discourse#  openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587

EHLO jai
AUTH PLAIN
AGZvcnVtQGFldGhlci1sYWJ... # 为了安全已截断
mail from: noreply@forum.aether-labs.fr
rcpt to: test-j0erqjxm2@srv1.mail-tester.com
data
subject: test smtp from inside

ok
.

…但是 discourse-doctor 命令仍然告诉我连接到 smtp-relay.sendinblue.com:587 失败。

所以我阅读了 discourse-doctor 脚本,发现测试链接到一个名为 emails:test 的 rake 任务,我在 lib/tasks/emails.rake 中找到了它,并看到当“执行超时”时会发生此消息。

是否有选项可以更改超时值,然后再认为执行已超时?

编辑:好的,所以如果我编辑 app/services/email_settings_validator.rb 并手动将超时设置为 30,连接就可以正常工作,但发送邮件仍然失败(我猜这可能与 TestMailer 相关,我可能无法增加这个…)

root@server-1-app:/var/www/discourse# rake emails:test[test-j0erqjxm2@srv1.mail-tester.com]
正在使用 smtp-relay.sendinblue.com:587,用户名:forum@aether-labs.fr,使用 plain 认证测试发送到 test-j0erqjxm2@srv1.mail-tester.com。
SMTP 服务器连接成功。
正在发送到 test-j0erqjxm2@srv1.mail-tester.com。。。
发送邮件失败。
执行超时

由于我的这个实例的配置几乎达到了 discourse 的最低要求(1 个 VCPU + 2GB RAM),我也许会尝试升级到更好的配置(例如 2 个 VCPU + 4GB RAM)。

您是否在环境变量中设置了:

DISCOURSE_SMTP_ENABLE_START_TLS: true

这是默认设置,所以您应该不需要它,但也许您将其关闭了?

它设置为 true,是的!
(我已编辑我之前的消息,其中包含我关于超时的实验……)

openssl 命令连接和协商 TLS 需要多长时间?

将近 10 秒

real	0m9.798s
user	0m0.007s
sys	0m0.010s

哇,那真是长得离谱。\n\n从宿主系统运行也需要这么长时间吗?

我刚做完测试
~10 秒(来自 Docker)
<1 秒(来自主机)(肯定是我按 Ctrl+D 停止的时间,几乎是瞬时的)

这是合理的。

看来你的容器网络有问题……这两个命令应该花费相同的时间:

(来自主机):point_down:t3:

○ → time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.277s
user	0m0.007s
sys	0m0.011s

(通过 docker):point_down:t3:

○ → docker run --rm discourse/base:2.0.20231023-1945 bash -c 'time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 </dev/null' > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.239s
user	0m0.006s
sys	0m0.000s
1 个赞

不是 :sob:

root@server-1:/var/discourse# time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 < /dev/null > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m0.126s
user	0m0.003s
sys	0m0.007s
root@server-1:/var/discourse# docker run --rm discourse/base:2.0.20231023-1945 bash -c 'time openssl s_client -starttls smtp -connect smtp-relay.sendinblue.com:587 < /dev/null' > /dev/null
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = *.sendinblue.com
verify return:1
250 STARTTLS
DONE

real	0m8.125s
user	0m0.007s
sys	0m0.000s

…我应该卸载/重装docker吗?
我只做了一些apt命令,并且让它保持docker-ce的默认设置,所以我不知道哪里出了问题……

我唯一做的修改是按照另一个帖子中的建议添加了dns,因为我最初遇到了“未知主机”错误。

root@server-1:/var/discourse# cat /etc/docker/daemon.json
{
  "dns": ["83.166.143.51", "83.166.143.52", "8.8.8.8"]
}

好的,它奏效了!

我更改了我的 /etc/docker/daemon.json,使 Google (8.8.8.8) 成为第一个,而不是最后一个,并且我获得了不错的 STARTTLS 响应时间……并且 discourse-doctor 成功发送了电子邮件 :slight_smile:

非常感谢您 @supermathie@pfaffman 的时间

我将在另一个帖子中添加一个说明,告诉大家 Google 应该排在列表的第一位!

并非所有建议都适用于所有情况。这也是为什么仅仅因为别人的建议对他们有效就照搬采纳的危险所在。

在您的情况下,谷歌的域名服务器似乎比您的 ISP 提供的域名服务器更可靠,所以您应该使用谷歌的。

2 个赞

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