##// END OF EJS Templates
Adds a delivery method that writes emails in tmp/emails for testing purpose....
Jean-Philippe Lang -
r7726:280faf6780d2
parent child
Show More
@@ -65,9 +65,9 end
65
65
66 ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
66 ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
67
67
68 # Adds :async_smtp and :async_sendmail delivery methods
69 # to perform email deliveries asynchronously
70 module AsynchronousMailer
68 module AsynchronousMailer
69 # Adds :async_smtp and :async_sendmail delivery methods
70 # to perform email deliveries asynchronously
71 %w(smtp sendmail).each do |type|
71 %w(smtp sendmail).each do |type|
72 define_method("perform_delivery_async_#{type}") do |mail|
72 define_method("perform_delivery_async_#{type}") do |mail|
73 Thread.start do
73 Thread.start do
@@ -75,6 +75,13 module AsynchronousMailer
75 end
75 end
76 end
76 end
77 end
77 end
78
79 # Adds a delivery method that writes emails in tmp/emails for testing purpose
80 def perform_delivery_tmp_file(mail)
81 dest_dir = File.join(Rails.root, 'tmp', 'emails')
82 Dir.mkdir(dest_dir) unless File.directory?(dest_dir)
83 File.open(File.join(dest_dir, mail.message_id.gsub(/[<>]/, '') + '.eml'), 'wb') {|f| f.write(mail.encoded) }
84 end
78 end
85 end
79
86
80 ActionMailer::Base.send :include, AsynchronousMailer
87 ActionMailer::Base.send :include, AsynchronousMailer
General Comments 0
You need to be logged in to leave comments. Login now