BUGFIX: catch STMP client errors in email sending background job

Will log the exception message in the skipped reason instead of keeping
the job in the queue whenever the email address is invalid
This commit is contained in:
Régis Hanol 2014-03-07 16:33:15 +01:00
parent b81f77541c
commit 18e9d319fd

View file

@ -9,6 +9,8 @@
require_dependency 'email/renderer'
require 'uri'
SMTP_CLIENT_ERRORS = [Net::SMTPFatalError, Net::SMTPSyntaxError]
module Email
class Sender
@ -77,12 +79,15 @@ module Email
@message.header['X-Discourse-Post-Id'] = nil
@message.header['X-Discourse-Reply-Key'] = nil
begin
@message.deliver
rescue SMTP_CLIENT_ERRORS => e
return skip(e.message)
end
# Save and return the email log
email_log.save!
email_log
end
def to_address