foodsoft/app/mail_receivers/bounce_mail_receiver.rb
2017-10-03 17:26:33 +02:00

20 lines
500 B
Ruby

class BounceMailReceiver
def self.regexp
/bounce\+(?<local>.*)=(?<domain>[^=]+)/
end
def initialize(match)
@address = "#{match[:local]}@#{match[:domain]}"
end
def received(data)
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