Skip to content
This repository
tree: 5a52523a80
Fetching contributors…

Cannot retrieve contributors at this time

file 21 lines (17 sloc) 0.544 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
require 'tmpdir'

module ActionMailer
  module DeliveryMethod

    # A delivery method implementation which writes all mails to a file.
    class File < Method
      self.settings = {
        :location => defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
      }

      def perform_delivery(mail)
        FileUtils.mkdir_p settings[:location]

        mail.destinations.uniq.each do |to|
          ::File.open(::File.join(settings[:location], to), 'a') { |f| f.write(mail) }
        end
      end
    end
  end
end
Something went wrong with that request. Please try again.