DEV: Report message-id, skip reason in rake email:test (#13674)
meta/t/185109 Additionally, print an extra warning if the `disable_emails` site setting is set.
This commit is contained in:
parent
c7cdebd931
commit
81d1a61d17
|
@ -179,20 +179,51 @@ task 'emails:test', [:email] => [:environment] do |_, args|
|
|||
end
|
||||
begin
|
||||
puts "Sending to #{email}. . . "
|
||||
Email::Sender.new(TestMailer.send_test(email), :test_message).send
|
||||
rescue => error
|
||||
puts "Sending mail failed."
|
||||
puts error.message
|
||||
else
|
||||
email_log = Email::Sender.new(TestMailer.send_test(email), :test_message).send
|
||||
case email_log
|
||||
when SkippedEmailLog
|
||||
puts <<~STR
|
||||
Mail was not sent.
|
||||
|
||||
Reason: #{email_log.reason}
|
||||
STR
|
||||
when EmailLog
|
||||
puts <<~STR
|
||||
Mail accepted by SMTP server.
|
||||
Message-ID: #{email_log.message_id}
|
||||
|
||||
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 for the above Message ID to see why it
|
||||
failed to deliver the message.
|
||||
STR
|
||||
when nil
|
||||
puts <<~STR
|
||||
Mail was not sent.
|
||||
|
||||
Check the SMTP server logs to see why it failed to deliver the message.
|
||||
Verify the status of the `disable_emails` site setting.
|
||||
STR
|
||||
else
|
||||
puts <<~STR
|
||||
SCRIPT BUG: Got back a #{email_log.class}
|
||||
#{email_log.inspect}
|
||||
|
||||
Mail may or may not have been sent. Check the destination mailbox.
|
||||
STR
|
||||
end
|
||||
rescue => error
|
||||
puts "Sending mail failed."
|
||||
puts error.message
|
||||
end
|
||||
|
||||
if SiteSetting.disable_emails != 'no'
|
||||
puts <<~STR
|
||||
|
||||
### WARNING
|
||||
The `disable_emails` site setting is currently set to #{SiteSetting.disable_emails}.
|
||||
Consider changing it to 'no' before performing any further troubleshooting.
|
||||
STR
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue