Class: ActionMailer::Base
- Inherits:
-
Object
- Object
- ActionMailer::Base
- Defined in:
- lib/action_mailer/ar_mailer.rb
Overview
Adds sending email through an ActiveRecord table as a delivery method for ActionMailer.
Constant Summary collapse
- @@email_class_name =
Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.
'Email'
Class Method Summary collapse
Instance Method Summary collapse
-
#perform_delivery_activerecord(mail) ⇒ Object
Adds
mail
to the Email table.
Class Method Details
.email_class ⇒ Object
17 18 19 |
# File 'lib/action_mailer/ar_mailer.rb', line 17 def self.email_class @@email_class_name.constantize end |
.email_class=(klass) ⇒ Object
13 14 15 |
# File 'lib/action_mailer/ar_mailer.rb', line 13 def self.email_class=(klass) @@email_class_name = klass.to_s end |
Instance Method Details
#perform_delivery_activerecord(mail) ⇒ Object
Adds mail
to the Email table. Only the first From address for mail
is used.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/action_mailer/ar_mailer.rb', line 25 def perform_delivery_activerecord(mail) require "action_mailer/ar_sendmail" destinations = mail.destinations mail.ready_to_send sender = (mail['return-path'] && mail['return-path'].spec) || mail.from.first destinations.each do |destination| m = self.class.email_class.create :mail => mail.encoded, :to => destination, :from => sender, :priority => (@priority.present? ? @priority : 3) if m.priority==-1 sendmail = ActionMailer::ARSendmail.new sendmail.deliver([m]) m.destroy end end end |