Repository is archived
No commit activity in last 3 years
No release in over 3 years
Wraps the deliver! method on ActionMailer to save the outgoing mail to a .eml file, which can be opened by most email clients. Also provides a mechanism for only sending to an approved list of email recipients, which is useful for ensuring your application doesn't send email outside of an organization.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3.2
~> 1.8.4
~> 10.0.3
~> 4.0.0
~> 2.13.0
>= 0
~> 1.0.4

Runtime

~> 2.3.18
 Project Readme

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 © 2010 Peter MacRobert. See LICENSE for details.