2017-08-19 16:24:02 +02:00
|
|
|
class BounceMailReceiver
|
|
|
|
|
|
|
|
def self.regexp
|
|
|
|
/bounce\+(?<local>.*)=(?<domain>[^=]+)/
|
|
|
|
end
|
|
|
|
|
2017-10-02 16:16:02 +02:00
|
|
|
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'
|
2017-10-02 16:16:02 +02:00
|
|
|
MailDeliveryStatus.create email: @address,
|
2017-08-19 16:24:02 +02:00
|
|
|
message: subject,
|
|
|
|
attachment_mime: 'message/rfc822',
|
|
|
|
attachment_data: data
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|