emails:test rake 任务在禁用电子邮件时,不应报告成功发送

类似于 Email test area should warn if emails are disabled

此处存在误导:

$ rake 'emails:test[michael@example.com]'
Testing sending to michael@example.com using mx-out:25.
SMTP server connection successful.
Sending to michael@example.com. . . 
Mail accepted by SMTP server.

If you do not receive the message, check your SPAM folder
or test again using a service like http://www.mail-tester.com/.

If the message is not delivered it is not a problem with Discourse.

Check the SMTP server logs to see why it failed to deliver the message.

在本例中,由于 SiteSetting.disable_emails == "non-staff",实际上并未发送邮件。

我们应在 rake 任务中对此发出警告。我们是否希望:

  • Email::Sender#send 中添加逻辑,返回一个指示消息是否已发送的值(例如:sent、skipped、disabled、no_message);
  • 或者,在 emails:test 任务中添加逻辑,仅针对 disable_emails 进行测试?
1 个赞

我觉得那段代码里有些部分跟我有关……

所以关于邮件已被接受的说法是假的?

我最希望的是,rake 任务能忽略“禁用邮件”的设置。如果有人能访问控制台,他们就应该能够发送测试邮件。

1 个赞

我同意,这是个很好的观点。也许最好既发送邮件,又报告邮件功能已禁用,以防万一。

2 个赞

我无法复现因 SiteSetting.disable_emails 导致消息无法发送的问题,但我已修改脚本,仅在返回 EmailLog 时报告成功,并针对 disable_emails 设置添加了额外警告。

$ bin/rake 'emails:test[]'
Testing sending to  using localhost:1025, username: with  auth.
SMTP server connection successful.
Sending to . . . 
Mail was not sent.

Reason: message.to is blank

### WARNING
The `disable_emails` site setting is currently set to non-staff.
Consider changing it to 'no' before performing any further troubleshooting.

以及

Sending to michael@example.com. . . 
Mail accepted by SMTP server.
Message-ID: dfaf1c88-aab6-474b-b50c-8c500afb6291@localhost

If you do not receive the message, check your SPAM folder
[...]

https://github.com/discourse/discourse/pull/13674

3 个赞

此主题在 21 小时后自动关闭。不再允许新回复。