2009-10-28 05:17:59 -04:00
|
|
|
require 'tmpdir'
|
2009-10-17 09:31:11 -04:00
|
|
|
|
2009-10-28 05:17:59 -04:00
|
|
|
module ActionMailer
|
|
|
|
module DeliveryMethod
|
|
|
|
|
|
|
|
# A delivery method implementation which writes all mails to a file.
|
|
|
|
class File < Method
|
|
|
|
self.settings = {
|
2009-12-02 23:01:01 -05:00
|
|
|
:location => defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
|
2009-10-28 05:17:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def perform_delivery(mail)
|
|
|
|
FileUtils.mkdir_p settings[:location]
|
|
|
|
|
2009-11-20 06:01:40 -05:00
|
|
|
mail.destinations.uniq.each do |to|
|
2009-10-28 05:17:59 -04:00
|
|
|
::File.open(::File.join(settings[:location], to), 'a') { |f| f.write(mail) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|