Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ActionMailer plugin that provides: save all outgoing emails to disk, and a safe-recipients list.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.document
.gitignore
.ruby-version
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
VERSION
actionmailer_extensions.gemspec

README.rdoc

actionmailer_extensions

These extensions wrap around the “deliver!” method on ActionMailer::Base to provide:

  • save all outgoing emails to disk, and

  • a list of recipient email addresses that are safe to receive mail. All other mail is not sent.

Note - only tested up to and including ActionMailer 2.3.8. Not tested on 3.0.

Saving email to disk

Sending email with markup from a web app is a pain in the ass because HTML markup renders differently in every email client. (If you don't believe me, check out this matrix of CSS support across the different email clients.

The only foolproof way to ensure that your content is rendering properly is to visually inspect the emails yourself. To get going, configure ActionMailer like so:

require 'actionmailer_extensions'
ActionMailer::Base.save_emails_to_disk  = true          # Defaults to false
ActionMailer::Base.email_output_dir     = "some/path"   # Defaults to "/tmp/actionmailer_output_emails"

Then send some emails with ActionMailer, and inspect the files in the output path that you specified. The emails are saved with a .eml extension which should open in your favourite email client for easy visual inspection.

Safe recipients list

Ever found that you want to limit the list of people that can receive email from a Rails app? This is a particularly handy feature during development when you don't want your (unfinished) application to send out real mail to people beyond the dev team.

Configure ActionMailer like so:

require 'actionmailer_extensions'
ActionMailer::Base.safe_recipients = ["pete@example.com", "dave@foo.com"]

Pete and Dave are now the only recipients that ActionMailer will send to, and all other mail will be quietly dropped. (And logged to disk, if save_emails_to_disk is enabled.)

Make sure that the recipients list contains the :any symbol in production mode.

ActionMailer::Base.safe_recipients = [:any]

This is enabled by default. Also note that an empty or nil recipients list means no mail will be sent out to anyone.

Install

gem source --add http://gemcutter.org
gem install actionmailer_extensions

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 Peter MacRobert. See LICENSE for details.

Something went wrong with that request. Please try again.