Class: ArMailerRails3::ActiveRecord
- Inherits:
-
Object
- Object
- ArMailerRails3::ActiveRecord
- 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
-
#email_class ⇒ Object
Returns the value of attribute email_class.
-
#email_class_name ⇒ Object
Returns the value of attribute email_class_name.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(options) ⇒ ActiveRecord
constructor
A new instance of ActiveRecord.
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() self.email_class = [:email_class] || Email end |
Instance Attribute Details
#email_class ⇒ Object
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_name ⇒ Object
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 52 53 54 55 56 57 |
# File 'lib/ar_mailer_rails3/active_record.rb', line 45 def deliver!(mail) require "action_mailer/ar_sendmail" destinations = mail.destinations sender = mail.return_path || mail.sender || mail.from_addrs.first destinations.each do |destination| m = self.email_class.create :mail => mail.encoded, :to => destination, :from => sender, :priority => (@priority.present? ? @priority : 3) if m.priority==-1 sendmail = ArMailerRails3::ARSendmail.new sendmail.deliver([m]) m.destroy end end end |