Add handling for bounce mails
This commit is contained in:
parent
97abcabffa
commit
578e929e0d
3 changed files with 24 additions and 0 deletions
17
app/mail_receivers/bounce_mail_receiver.rb
Normal file
17
app/mail_receivers/bounce_mail_receiver.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class BounceMailReceiver
|
||||
|
||||
def self.regexp
|
||||
/bounce\+(?<local>.*)=(?<domain>[^=]+)/
|
||||
end
|
||||
|
||||
def received(match, data)
|
||||
address = "#{match[:local]}@#{match[:domain]}"
|
||||
mail = Mail.new data
|
||||
subject = mail.subject || 'Unknown bounce error'
|
||||
MailDeliveryStatus.create email: address,
|
||||
message: subject,
|
||||
attachment_mime: 'message/rfc822',
|
||||
attachment_data: data
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue