Adds :async_smtp and :async_sendmail delivery methods to perform email deliveries asynchronously.

Code from http://www.datanoise.com/articles/2006/7/14/asynchronous-email-delivery.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2339 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-01-31 11:43:54 +00:00
parent da941734d7
commit ef903ba70e
1 changed files with 14 additions and 0 deletions

View File

@ -15,3 +15,17 @@ ActiveRecord::Errors.default_error_messages = {
} if ActiveRecord::Errors.respond_to?('default_error_messages=') } if ActiveRecord::Errors.respond_to?('default_error_messages=')
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
# Adds :async_smtp and :async_sendmail delivery methods
# to perform email deliveries asynchronously
module AsynchronousMailer
%w(smtp sendmail).each do |type|
define_method("perform_delivery_async_#{type}") do |mail|
Thread.start do
send "perform_delivery_#{type}", mail
end
end
end
end
ActionMailer::Base.send :include, AsynchronousMailer