Improve the interface of FoodsoftMailReceiver

This commit is contained in:
Patrick Gansterer 2017-10-02 16:16:02 +02:00
parent e9bae618ed
commit e017a1196e
3 changed files with 24 additions and 19 deletions

View file

@ -4,11 +4,14 @@ class BounceMailReceiver
/bounce\+(?<local>.*)=(?<domain>[^=]+)/
end
def received(match, data)
address = "#{match[:local]}@#{match[:domain]}"
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,
MailDeliveryStatus.create email: @address,
message: subject,
attachment_mime: 'message/rfc822',
attachment_data: data