Add handling for bounce mails

This commit is contained in:
Patrick Gansterer 2017-08-19 16:24:02 +02:00
parent 97abcabffa
commit 578e929e0d
3 changed files with 24 additions and 0 deletions

View 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