Sanitize Email plugin

Plugin details

SanitizeEmail allows you to play with your application's email abilities without worrying that emails will get sent to actual live addresses.

Websitehttp://galtzo.blogspot.com/2008/11/sanitize-email-never-worry-about.html Repositorygit://github.com/pboling/sanitize_email.git Author Peter H. Boling Tags email LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/pboling/sanitize_email.git

Example
=======

So here's how you can use force_sanitize to override the override.

Even if you set:

      ActionMailer::Base.local_environments = %w( development )


And are in the development environment, you can override the override anywhere in your code.

  class User < ActiveRecord::Base
    def test_signup_email_me_only
      UserMailer.force_sanitize = true
      UserMailer.deliver_signup_notification(self)
      UserMailer.force_sanitize = nil
    end

    def test_signup_email_user_only
      UserMailer.force_sanitize = false
      UserMailer.deliver_signup_notification(self)
      UserMailer.force_sanitize = nil
    end
  
    #this third method would conditionally use the overridden recipients based on current Rails environment
    def test_signup_email_environment
      UserMailer.deliver_signup_notification(self)
    end
  
  end


Load the console with ruby script/console and regardless of what environment you are in:

> User.find(4).test_signup_email_me_only


and the email will have it's recipients, bcc, and cc overridden to be whatever you set the sanitized values to be.
Then if you want to send it to the actual user, instead of yourself

> User.find(4).test_signup_email_user_only

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago