foodsoft/app/mail_receivers/bounce_mail_receiver.rb

19 lines
498 B
Ruby
Raw Permalink Normal View History

2017-08-19 16:24:02 +02:00
class BounceMailReceiver
def self.regexp
/bounce\+(?<local>.*)=(?<domain>[^=]+)/
end
def initialize(match)
@address = "#{match[:local]}@#{match[:domain]}"
end
def received(data)
2017-08-19 16:24:02 +02:00
mail = Mail.new data
subject = mail.subject || 'Unknown bounce error'
MailDeliveryStatus.create email: @address,
2017-08-19 16:24:02 +02:00
message: subject,
attachment_mime: 'message/rfc822',
attachment_data: data
end
end