Skip to content

stemps/mailsafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Climate Build Status

Mailsafe

Safe emailing for Rails. Prevents you from sending emails to real customers from non-production environments. You can choose to either re-route all emails to a single developer account or allow only recipients of your own domain.

Installation

Add this line to your application's Gemfile:

gem 'mailsafe'

And then execute:

$ bundle

Usage

You can re-route all emails to your developer email account by adding this your development.rb file

Mailsafe.setup do |config|
  config.override_receiver = "developer@devco.com"
end

The email subjects will be delivered to your account and prefixed with the original receiver in square brackets.

You can send emails to the intended recipients but only to a whitelist of receipient domains (e.g. helpful for a staging environment where you want to send emails to your company's and your client's domain)

Mailsafe.setup do |config|
  config.allowed_domain = "devco.com, clientco.com"
end

If you are running multiple environments with mailsafe it can help to know which environment an email came from. You can have mailsafe prefix the subject line with [environment name]

config.prefix_email_subject_with_rails_env = true

Caveat

In order to filter (as in not send) emails I had to monkey patch the Mail#deliver method. If this makes you feel uneasy, better try out a different solution.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Safe emailing for Rails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages