Sha256: 066475a89065f24ba2309db7930a41b0f1a183b12d2d292f8fbe65af9d460234

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

##
# Adds sending email through an ActiveRecord table as a delivery method for
# ActionMailer.
#

class ActionMailer::Base

  ##
  # Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.
  #
  @@email_class_name = 'Email'

  def self.email_class=(klass)
    @@email_class_name = klass.to_s
  end

  def self.email_class
    @@email_class_name.constantize
  end
  
  ##
  # Set the name of the yml config file for smtp.
  #
  @@smtp_settings_path_name = "#{Rails.root}/config/smtp_settings.yml"

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

  def self.smtp_settings_path
    @@smtp_settings_path_name
  end

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

  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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foresth-ar_mailer-2.1.8 lib/action_mailer/ar_mailer.rb