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