Sha256: 446a42880dbcd916ea83a18950c9bda39164aaf063e4b1a87ad10d80095e9a9b

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 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

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

  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

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
prioritized_ar_mailer-2.1.11 lib/action_mailer/ar_mailer.rb
gsoni-ar_mailer-2.1.11 lib/action_mailer/ar_mailer.rb
gsoni-ar_mailer-2.1.10 lib/action_mailer/ar_mailer.rb
gsoni-ar_mailer-2.1.9 lib/action_mailer/ar_mailer.rb