Sha256: f2092e93bc378a75add6987c4959d570e859cd5cacf7051eb92264ca864ef857

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

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

  ##
  # 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

7 entries across 7 versions & 3 rubygems

Version Path
leftbrained-ar_mailer-2.1.11 lib/action_mailer/ar_mailer.rb
adzap-ar_mailer-2.1.10 lib/action_mailer/ar_mailer.rb
adzap-ar_mailer-2.1.9 lib/action_mailer/ar_mailer.rb
leftbrained-ar_mailer-2.1.9 lib/action_mailer/ar_mailer.rb
foreverman-ar_mailer-2.1.9 lib/action_mailer/ar_mailer.rb
foreverman-ar_mailer-2.1.8 lib/action_mailer/ar_mailer.rb
adzap-ar_mailer-2.1.8 lib/action_mailer/ar_mailer.rb