Class: ActionMailer::Base

Inherits:
Object
  • Object
show all
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'
@@smtp_settings_path_name =

Set the name of the yml config file for smtp.

"#{Rails.root}/config/smtp_settings.yml"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.email_classObject



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

.smtp_settings_pathObject



30
31
32
# File 'lib/action_mailer/ar_mailer.rb', line 30

def self.smtp_settings_path
  @@smtp_settings_path_name
end

.smtp_settings_path=(filename) ⇒ Object



26
27
28
# File 'lib/action_mailer/ar_mailer.rb', line 26

def self.smtp_settings_path=(filename)
  @@smtp_settings_path_name = filename
end

Instance Method Details

#perform_delivery_activerecord(mail) ⇒ Object

Adds mail to the Email table. Only the first From address for mail is used.



38
39
40
41
42
43
44
45
# File 'lib/action_mailer/ar_mailer.rb', line 38

def perform_delivery_activerecord(mail)
  destinations = mail.destinations
  mail.ready_to_send
  sender = (mail['return-path'] && mail['return-path'].spec) || mail.from.first
  destinations.each do |destination|
    self.class.email_class.create :mail => mail.encoded, :to => destination, :from => sender
  end
end