From ef903ba70ef456b2e7c515f5e4895e7749bfcac2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 31 Jan 2009 11:43:54 +0000 Subject: 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 --- config/initializers/10-patches.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'config/initializers/10-patches.rb') diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 5fbb91abf..d1235d93f 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -15,3 +15,17 @@ ActiveRecord::Errors.default_error_messages = { } if ActiveRecord::Errors.respond_to?('default_error_messages=') 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 -- cgit v1.2.3