EmailInterceptor
This is a very simple gem that works as an ActiveMailer email interceptor. It allows you to selectively send some emails (called :internal) while re-writing all other emails with a test account or other email address.
The intention of this is to prevent real users from being emailed from non-production environments, such as staging.
Installation
Add this line to your application's Gemfile:
gem 'email_interceptor'
And then execute:
$ bundle
Or install it yourself as:
$ gem install email_interceptor
Usage
To use this in Rails, one can pass it to
ActionMailer.register_interceptor in an initializer, i.e.
email_interceptor = EmailInterceptor.new(:internal_only, {
:fake_email_address => '[email protected]',
:internal_recipient_matcher => /@this.can.be.a.regex.com$/,
:logger_file => Rails.root.join('/log/mailer.log')
})
ActionMailer::Base.register_interceptor(email_interceptor)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request