17 lines
474 B
Ruby
17 lines
474 B
Ruby
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
|