foodsoft/app/mail_receivers/bounce_mail_receiver.rb

18 lines
474 B
Ruby
Raw Normal View History

2017-08-19 16:24:02 +02:00
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