diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index b77409b..8779aef 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -220,9 +220,13 @@ module ActionMailer #:nodoc: # * :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail. # * :arguments - The command line arguments. Defaults to -i -t. # + # * file_settings - Allows you to override options for the :file delivery method. + # * :location - The directory into which emails will be written. Defaults to the application tmp/mails. + # # * raise_delivery_errors - Whether or not errors should be raised if the email fails to be delivered. # - # * delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, and :test. + # * delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test, + # and :file. # # * perform_deliveries - Determines whether deliver_* methods are actually carried out. By default they are, # but this can be turned off to help functional testing. @@ -275,6 +279,11 @@ module ActionMailer #:nodoc: } cattr_accessor :sendmail_settings + @@file_settings = { + :location => "#{Rails.root}/tmp/mails", + } + cattr_accessor :file_settings + @@raise_delivery_errors = true cattr_accessor :raise_delivery_errors @@ -696,6 +705,12 @@ module ActionMailer #:nodoc: def perform_delivery_test(mail) deliveries << mail end + + def perform_delivery_file(mail) + mail.to.each do |to| + File.open(File.join(file_settings[:location], to), 'a') { |f| f.write(mail) } + end + end end Base.class_eval do