Class: Remail::ActionMailer

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

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ ActionMailer

Returns a new instance of ActionMailer.



44
45
46
47
48
# File 'lib/remail.rb', line 44

def initialize(settings)
  settings.each {|key, value| 
    Remail.send("#{key}=", value) 
  }
end

Instance Method Details

#deliver!(mail) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/remail.rb', line 50

def deliver!(mail)
  remail = Remail::Email.new
  
  %w{to from cc bcc reply_to}.each {|attr|
    value = mail.send(attr)
    next unless value
    remail.send("#{attr}=", value.join(", "))
  }      
  
  remail.subject  = mail.subject
  
  text_body   = mail.text_part ? mail.text_part.body : mail.body
  html_body   = mail.html_part && mail.html_part.body
  remail.body = text_body.encoded if text_body
  remail.html = html_body.encoded if html_body
  
  remail.save!
end