diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-10-10 17:13:09 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-10-10 17:13:09 +0000 |
commit | 0c78056a69cc3bee7fb1cd3261046995db55bfdf (patch) | |
tree | 67883c68edad43b2e6f96e9ea8b864370a6b207c /config/initializers | |
parent | 5533eeff239e024539f3ddd5b2ffe3528144beef (diff) | |
download | redmine-0c78056a69cc3bee7fb1cd3261046995db55bfdf.tar.gz redmine-0c78056a69cc3bee7fb1cd3261046995db55bfdf.zip |
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
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/10-patches.rb | 31 |
1 files changed, 2 insertions, 29 deletions
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 |