Parent

Methods

Class Index [+]

Quicksearch

Mail::FileDelivery

FileDelivery class delivers emails into multiple files based on the destination address. Each file is appended to if it already exists.

So if you have an email going to fred@test, bob@test, joe@anothertest, and you set your location path to /path/to/mails then FileDelivery will create the directory if it does not exist, and put one copy of the email in three files, called “fred@test”, “bob@test” and “joe@anothertest“

Make sure the path you specify with :location is writable by the Ruby process running Mail.

Attributes

settings[RW]

Public Class Methods

new(values) click to toggle source
    # File lib/mail/network/delivery_methods/file_delivery.rb, line 21
21:     def initialize(values)
22:       self.settings = { :location => './mails' }.merge!(values)
23:     end

Public Instance Methods

deliver!(mail) click to toggle source
    # File lib/mail/network/delivery_methods/file_delivery.rb, line 27
27:     def deliver!(mail)
28:       if ::File.respond_to?(:makedirs)
29:         ::File.makedirs settings[:location]
30:       else
31:         ::FileUtils.mkdir_p settings[:location]
32:       end
33: 
34:       mail.destinations.uniq.each do |to|
35:         ::File.open(::File.join(settings[:location], to), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" }
36:       end
37:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.