Logged SMTP Delivery

require 'action_mailer/logged_smtp_delivery'
config.action_mailer.logged_smtp_settings = {
  ... normal smtp settings ...,
  logger: Logger.new, # progress info
  mail_file_logger: FileLogger.new # write encoded mails for storage, must return path they were stored in
}


Detailed log stream with message id prefix. Example:

<[email protected]> stored at example/log/mails/outbound/2011-07-23/7_13462_2.eml
<[email protected]> X-Delivery-Context: [users/1/welcome]
<[email protected]> sender: [email protected]
<[email protected]> destinations: [email protected]
<[email protected]> done #<Net::SMTP::Response:0x10bbee680 @string="250 2.0.0 Ok: queued as 87BF716D7901\n", @status="250">

Logs an identification header to quickly locate logs for a specific email/entity

config.action_mailer.logged_smtp_settings[:log_header] = 'X-Delivery-Context'

class UsersMailer < ActionMailer::Base

  def welcome(user)
    headers['X-Delivery-Context'] = "users/#{user.id}/welcome"

    # ...
  end
end


UsersMailer.welcome(user).deliver
# ActionMailer::Base.logger -> 
# <[email protected]> X-Delivery-Context: [users/1/welcome]

Doesn't render BCC recipients

License: Apache V2