Class: ArMailerRails3::ActiveRecord

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

Overview

A delivery method implementation which sends via sendmail.

To use this, first find out where the sendmail binary is on your computer, if you are on a mac or unix box, it is usually in /usr/sbin/sendmail, this will be your sendmail location.

Mail.defaults do
  delivery_method :sendmail
end

Or if your sendmail binary is not at ‘/usr/sbin/sendmail’

Mail.defaults do
  delivery_method :sendmail, :location => '/absolute/path/to/your/sendmail'
end

Then just deliver the email as normal:

Mail.deliver do
  to '[email protected]'
  from '[email protected]'
  subject 'testing sendmail'
  body 'testing sendmail'
end

Or by calling deliver on a Mail message

mail = Mail.new do
  to '[email protected]'
  from '[email protected]'
  subject 'testing sendmail'
  body 'testing sendmail'
end

mail.deliver!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



39
40
41
# File 'lib/ar_mailer_rails3/active_record.rb', line 39

def initialize(options)
  self.email_class = options[:email_class] || Email
end

Instance Attribute Details

#email_classObject

Returns the value of attribute email_class.



43
44
45
# File 'lib/ar_mailer_rails3/active_record.rb', line 43

def email_class
  @email_class
end

#email_class_nameObject

Returns the value of attribute email_class_name.



43
44
45
# File 'lib/ar_mailer_rails3/active_record.rb', line 43

def email_class_name
  @email_class_name
end

Instance Method Details

#deliver!(mail) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/ar_mailer_rails3/active_record.rb', line 45

def deliver!(mail)
  destinations = mail.destinations
  sender = mail.return_path || mail.sender || mail.from_addrs.first
  destinations.each do |destination|
    self.email_class.create :mail => mail.encoded, :to => destination, :from => sender
  end
end