diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-31 11:43:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-31 11:43:54 +0000 |
commit | ef903ba70ef456b2e7c515f5e4895e7749bfcac2 (patch) | |
tree | b392cb42559808ec6961f2155d16a7d8b9c1fc3e /config/initializers/10-patches.rb | |
parent | da941734d769679def1deee9ff8d32f0a579311a (diff) | |
download | redmine-ef903ba70ef456b2e7c515f5e4895e7749bfcac2.tar.gz redmine-ef903ba70ef456b2e7c515f5e4895e7749bfcac2.zip |
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
Diffstat (limited to 'config/initializers/10-patches.rb')
-rw-r--r-- | config/initializers/10-patches.rb | 14 |
1 files changed, 14 insertions, 0 deletions
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 |