mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
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:
parent
b81f77541c
commit
18e9d319fd
1 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue