Sha256: f0faec2f3360fd307624c4d66c94019cbcd5b2554ea095e3c724ef7c3aa6e114

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

module ArMailerRails3
  # A delivery method implementation which sends via sendmail.
  # 
  # To use this, first find out where the sendmail binary is on your computer,
  # if you are on a mac or unix box, it is usually in /usr/sbin/sendmail, this will
  # be your sendmail location.
  # 
  #   Mail.defaults do
  #     delivery_method :sendmail
  #   end
  # 
  # Or if your sendmail binary is not at '/usr/sbin/sendmail'
  # 
  #   Mail.defaults do
  #     delivery_method :sendmail, :location => '/absolute/path/to/your/sendmail'
  #   end
  # 
  # Then just deliver the email as normal:
  # 
  #   Mail.deliver do
  #     to 'mikel@test.lindsaar.net'
  #     from 'ada@test.lindsaar.net'
  #     subject 'testing sendmail'
  #     body 'testing sendmail'
  #   end
  # 
  # Or by calling deliver on a Mail message
  # 
  #   mail = Mail.new do
  #     to 'mikel@test.lindsaar.net'
  #     from 'ada@test.lindsaar.net'
  #     subject 'testing sendmail'
  #     body 'testing sendmail'
  #   end
  # 
  #   mail.deliver!
  class ActiveRecord
    
    def initialize(options)
      self.email_class = options[:email_class] || Email
    end
    
    attr_accessor :email_class_name, :email_class
    
    def deliver!(mail)
      require "action_mailer/ar_sendmail"
      destinations = mail.destinations
      sender = mail.return_path || mail.sender || mail.from_addrs.first
      destinations.each do |destination|
        m = self.email_class.create :mail => mail.encoded, :to => destination, :from => sender, :priority => (@priority.present? ? @priority : 3)
        if m.priority==-1
          sendmail = ArMailerRails3::ARSendmail.new
          sendmail.deliver([m])
          m.destroy
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
prioritized_ar_mailer_rails3-2.1.12 lib/ar_mailer_rails3/active_record.rb
gsoni-ar_mailer_rails3-2.1.12 lib/ar_mailer_rails3/active_record.rb