Class: BounceMailReceiver

Inherits:
Object
  • Object
show all
Defined in:
app/mail_receivers/bounce_mail_receiver.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match) ⇒ BounceMailReceiver

Returns a new instance of BounceMailReceiver


7
8
9
# File 'app/mail_receivers/bounce_mail_receiver.rb', line 7

def initialize(match)
  @address = "#{match[:local]}@#{match[:domain]}"
end

Class Method Details

.regexpObject


3
4
5
# File 'app/mail_receivers/bounce_mail_receiver.rb', line 3

def self.regexp
  /bounce\+(?<local>.*)=(?<domain>[^=]+)/
end

Instance Method Details

#received(data) ⇒ Object


11
12
13
14
15
16
17
18
# File 'app/mail_receivers/bounce_mail_receiver.rb', line 11

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