Class: MaileroobyDeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/mailerooby/mailerooby_delivery_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ MaileroobyDeliveryMethod

Returns a new instance of MaileroobyDeliveryMethod.



4
5
6
# File 'lib/mailerooby/mailerooby_delivery_method.rb', line 4

def initialize(values)
  self.settings = values
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



8
9
10
# File 'lib/mailerooby/mailerooby_delivery_method.rb', line 8

def settings
  @settings
end

Instance Method Details

#deliver!(mail) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mailerooby/mailerooby_delivery_method.rb', line 10

def deliver!(mail)
    from = mail.from.join(', ')
    to = mail.to.join(', ')
    subject = mail.subject
    body = mail.body.raw_source
    cc = mail.cc.join(', ') if mail.cc.present?
    bcc = mail.bcc.join(', ') if mail.bcc.present?
    reply_to = mail.reply_to if mail.reply_to.present?
    attachments = extract_attachments(mail)
    # Send the email via Maileroob API
    response = Mailerooby::EmailSender.send_email(from: from, 
                                                  to: to, 
                                                  subject: subject, 
                                                  body: body, 
                                                  cc: cc, 
                                                  bcc: bcc, 
                                                  reply_to: reply_to, 
                                                  attachments: attachments)

    # Check the response and raise an error if necessary
    handle_response(response)
end