summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/mailer.rb11
-rw-r--r--lib/tasks/reminder.rake6
2 files changed, 15 insertions, 2 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 22b99edf6..96bb83c57 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -372,6 +372,17 @@ class Mailer < ActionMailer::Base
ActionMailer::Base.perform_deliveries = was_enabled
end
+ # Sends emails synchronously in the given block
+ def self.with_synched_deliveries(&block)
+ saved_method = ActionMailer::Base.delivery_method
+ if m = saved_method.to_s.match(%r{^async_(.+)$})
+ ActionMailer::Base.delivery_method = m[1].to_sym
+ end
+ yield
+ ensure
+ ActionMailer::Base.delivery_method = saved_method
+ end
+
private
def initialize_defaults(method_name)
super
diff --git a/lib/tasks/reminder.rake b/lib/tasks/reminder.rake
index d11c7cebb..3997ee369 100644
--- a/lib/tasks/reminder.rake
+++ b/lib/tasks/reminder.rake
@@ -35,7 +35,9 @@ namespace :redmine do
options[:project] = ENV['project'] if ENV['project']
options[:tracker] = ENV['tracker'].to_i if ENV['tracker']
options[:users] = (ENV['users'] || '').split(',').each(&:strip!)
-
- Mailer.reminders(options)
+
+ Mailer.with_synched_deliveries do
+ Mailer.reminders(options)
+ end
end
end