0.0
No commit activity in last 3 years
No release in over 3 years
Protect yourself for ever accidentally sendmail emails from an environment other than production. MailRedirector lets you specify an email address to redirect all mail send by ActionMailer to. It also sets the X-Originally-To header to the original recipients, ensuring you can inspect to message and verify it would have gone to the correct recipients.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.0.0
 Project Readme

Mail Redirector

Installation

In Your Gemfile

gem 'mail-redirector'

In config/initializers/mail-redirector.rb

MailRedirector.setup_interceptor 'test@example.com'

That's it!

What it's doing

In all environments other than PRODUCTION or TEST, mail sent through ActionMailer will be redirected to test@example.com. No mail will be sent to its original destination. Instead, the X-Originally-To mail header will be set, allowing you to determine who the mail would have gone to had it not been redirected.

Mail in the TEST environment is specifically NOT redirected on the assumption that it is more convenient to configure action mailer to test delivery mode and still allow the tests to have access to the original to field for testing purposes.

I want more control!

If you want to change what addresses mail is redirected to in each environment, then INSTEAD of calling setup_interceptor, place a line of code like this:

ActionMailer::Base.register_interceptor(MailRedirector.new("test@example.com"))

In each environment file, or wherever makes sense for you.

Happy redirecting!