diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-19 13:51:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-19 13:51:34 +0000 |
commit | 280faf6780d286dd0efefbf7b3f7b5af1d3ebc72 (patch) | |
tree | 38c9e10c799ca0711c3839da39b411c25cb305b9 /config/initializers/10-patches.rb | |
parent | 886310055bd12dc4ffccf14c0691dc7d7204a2bb (diff) | |
download | redmine-280faf6780d286dd0efefbf7b3f7b5af1d3ebc72.tar.gz redmine-280faf6780d286dd0efefbf7b3f7b5af1d3ebc72.zip |
Adds a delivery method that writes emails in tmp/emails for testing purpose.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7846 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config/initializers/10-patches.rb')
-rw-r--r-- | config/initializers/10-patches.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index aa51c0e7a..f409f6611 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -65,9 +65,9 @@ end 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 + # Adds :async_smtp and :async_sendmail delivery methods + # to perform email deliveries asynchronously %w(smtp sendmail).each do |type| define_method("perform_delivery_async_#{type}") do |mail| Thread.start do @@ -75,6 +75,13 @@ module AsynchronousMailer end end end + + # Adds a delivery method that writes emails in tmp/emails for testing purpose + def perform_delivery_tmp_file(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) } + end end ActionMailer::Base.send :include, AsynchronousMailer |