tasks/emails.rake: catch exception and puts message (#12024)

* tasks/emails.rake: catch exception and puts message

* add username and auth
This commit is contained in:
T 2021-02-10 15:42:21 +00:00 committed by GitHub
parent ad7ca46231
commit 1a159de36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -78,7 +78,7 @@ task 'emails:test', [:email] => [:environment] do |_, args|
STR STR
end end
puts "Testing sending to #{email} using #{smtp[:address]}:#{smtp[:port]}." puts "Testing sending to #{email} using #{smtp[:address]}:#{smtp[:port]}, username:#{smtp[:user_name]} with #{smtp[:authentication]} auth."
# We would like to do this, but Net::SMTP errors out using starttls # We would like to do this, but Net::SMTP errors out using starttls
#Net::SMTP.start(smtp[:address], smtp[:port]) do |s| #Net::SMTP.start(smtp[:address], smtp[:port]) do |s|
@ -169,8 +169,9 @@ task 'emails:test', [:email] => [:environment] do |_, args|
begin begin
puts "Sending to #{email}. . . " puts "Sending to #{email}. . . "
Email::Sender.new(TestMailer.send_test(email), :test_message).send Email::Sender.new(TestMailer.send_test(email), :test_message).send
rescue rescue => error
puts "Sending mail failed." puts "Sending mail failed."
puts error.message
else else
puts <<~STR puts <<~STR
Mail accepted by SMTP server. Mail accepted by SMTP server.