From 0c78056a69cc3bee7fb1cd3261046995db55bfdf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 10 Oct 2018 17:13:09 +0000 Subject: Send emails asynchronously (#26791). Custom async_* delivery methods are removed in favor of ActiveJob (Async by default). git-svn-id: http://svn.redmine.org/redmine/trunk@17588 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/initializers/10-patches.rb | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'config/initializers') diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index b5698b436..8d73eba2c 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -106,35 +106,18 @@ end require 'mail' module DeliveryMethods - class AsyncSMTP < ::Mail::SMTP - def deliver!(*args) - Thread.start do - super *args - end - end - end - - class AsyncSendmail < ::Mail::Sendmail - def deliver!(*args) - Thread.start do - super *args - end - end - end - class TmpFile def initialize(*args); end def deliver!(mail) dest_dir = File.join(Rails.root, 'tmp', 'emails') Dir.mkdir(dest_dir) unless File.directory?(dest_dir) - File.open(File.join(dest_dir, mail.message_id.gsub(/[<>]/, '') + '.eml'), 'wb') {|f| f.write(mail.encoded) } + filename = "#{Time.now.to_i}_#{mail.message_id.gsub(/[<>]/, '')}.eml" + File.open(File.join(dest_dir, filename), 'wb') {|f| f.write(mail.encoded) } end end end -ActionMailer::Base.add_delivery_method :async_smtp, DeliveryMethods::AsyncSMTP -ActionMailer::Base.add_delivery_method :async_sendmail, DeliveryMethods::AsyncSendmail ActionMailer::Base.add_delivery_method :tmp_file, DeliveryMethods::TmpFile # Changes how sent emails are logged @@ -155,16 +138,6 @@ module ActionMailer end end -# #deliver is deprecated in Rails 4.2 -# Prevents massive deprecation warnings -module ActionMailer - class MessageDelivery < Delegator - def deliver - deliver_now - end - end -end - module ActionController module MimeResponds class Collector -- cgit v1.2.3