github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

myronmarston / mail_safe

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 57
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (1)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • master ✓
    • rails3
  • Tags (1)
    • v0.1.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Keep your ActionMailer emails from escaping into the wild during development. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Updated gemspec. 
Myron Marston (author)
Fri Nov 06 10:56:31 -0800 2009
commit  313cba5995d7fca8aded1ae2e888d0c76cb97823
tree    f3f9a7ba67dafa335a5c57899501ab215533235e
parent  29a3e7a47f4134048ad2ba004fc6243bab751a6d
mail_safe /
name age
history
message
file .document Thu Aug 27 23:58:37 -0700 2009 Initial commit to mail_safe. [Myron Marston]
file .gitignore Thu Aug 27 23:58:37 -0700 2009 Initial commit to mail_safe. [Myron Marston]
file LICENSE Thu Aug 27 23:58:37 -0700 2009 Initial commit to mail_safe. [Myron Marston]
file README.rdoc Fri Nov 06 10:55:21 -0800 2009 Updated the readme. [Myron Marston]
file Rakefile Fri Aug 28 08:25:36 -0700 2009 Fixed up rakefile a bit. [Myron Marston]
file VERSION.yml Fri Nov 06 10:55:36 -0800 2009 Version bump to 0.2.0 [Myron Marston]
directory lib/ Fri Nov 06 10:46:26 -0800 2009 Use the email address set in git config if Mail... [Myron Marston]
file mail_safe.gemspec Fri Nov 06 10:56:31 -0800 2009 Updated gemspec. [Myron Marston]
directory test/ Fri Nov 06 10:46:26 -0800 2009 Use the email address set in git config if Mail... [Myron Marston]
README.rdoc

mail_safe

Mail safe provides a safety net while you’re developing an application that uses ActionMailer. It keeps emails from escaping into the wild.

Once you’ve installed and configured this gem, you can rest assure that your app won’t send emails to external email addresses. Instead, emails that would normally be delivered to external addresses will be sent to an address of your choosing, and the body of the email will be appended with a note stating where the email was originally intended to go.

Download

Github: github.com/myronmarston/mail_safe

Gem:

  gem install mail_safe --source http://gemcutter.org

Installation

Load the gem in your non-production environments using Rails’ 2.1+ gem support. For example, I’m loading this in config/environments/development.rb and config/environments/staging.rb:

  config.gem 'mail_safe', :source => 'http://gemcutter.org'

IMPORTANT: Be sure not to load this in your production environment, otherwise, your emails won’t be sent to the proper recipients. In your test environment, you probably won’t want this, either—rails ensures that no emails are ever sent in the test environment, and tests that check outbound email recipients may fail.

Configuration

In many cases, no configuration is necessary. If you have git installed, and you’ve registered your email address with it (check with "git config user.email" in your shell), mail safe will use this. All emails will be sent to this address.

Otherwise, you can configure mail safe’s behavior. Create a file at config/initializers/mail_safe.rb, similar to the following:

  if defined?(MailSafe::Config)
    MailSafe::Config.internal_address_definition = /.*@my-domain\.com/i
    MailSafe::Config.replacement_address = 'me@my-domain.com'
  end

The internal address definition determines which addresses will be ignored (i.e. sent normally) and which will be replaced. Email being sent to internal addresses will be sent normally; all other email addresses will be replaced by the replacement address.

These settings can also take procs if you need something more flexible:

  if defined?(MailSafe::Config)
    MailSafe::Config.internal_address_definition = lambda { |address|
      address =~ /.*@domain1\.com/i ||
      address =~ /.*@domain2\.com/i ||
      address == 'full-address@domain.com'
    }

    # Useful if your mail server allows + dynamic email addresses like gmail.
    MailSafe::Config.replacement_address = lambda { |address| "my-address+#{address.gsub(/[\w\-.]/, '_')}@gmail.com" }
  end

When mail safe replaces an email address, it appends a notice to the bottom of the email body, such as:

  **************************************************
  This email originally had different recipients,
  but MailSafe has prevented it from being sent to them.

  The original recipients were:
  - to:
   - external-address-1@domain.com
   - external-address-2@domain.com
  - cc:
   - external-address-3@domain.com

  **************************************************

Copyright

Copyright © 2009 Myron Marston, Kashless.org. See LICENSE for details.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server