Skip to content

Instantly share code, notes, and snippets.

@adzap
Created March 18, 2009 20:58
Show Gist options
  • Save adzap/81402 to your computer and use it in GitHub Desktop.
Save adzap/81402 to your computer and use it in GitHub Desktop.
require 'action_mailer'
##
# Adds sending email through an ActiveRecord table as a delivery method for
# ActionMailer.
#
class ActionMailer::ARMailer < ActionMailer::Base
def self.inherited(sub)
logger.warn('The ActionMailer::ARMailer class has been deprecated. Will be removed in version 2.1. Just use ActionMailer::Base.')
end
end
class ActionMailer::Base
class_inheritable_accessor :email_class
self.email_class = Email
##
# Adds +mail+ to the Email table. Only the first From address for +mail+ is
# used.
def perform_delivery_activerecord(mail)
mail.destinations.each do |destination|
self.class.email_class.create :mail => mail.encoded, :to => destination,
:from => mail.from.first
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment