The emails:test rake task should not report successful delivery when email is disabled

I couldn’t repro the message not sending due to SiteSetting.disable_emails, but I did change the script to only report success if an EmailLog was returned, and an extra warning for the disable_emails setting.

$ 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.

and

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 Likes