<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SmartLogic Solutions Blog &#187; ActionMailer</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/ruby-on-rails/actionmailer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using Sanitize Email to Preview HTML Emails Locally</title>
		<link>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 13:26:04 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[John Trupiano]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nick Gauthier]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=605</guid>
		<description><![CDATA[John Trupiano has a great post to get you started with sanitize_email for Ruby on Rails. I wanted to preview my HTML emails without having to fill up my online email inboxes with tons of email (and then I&#8217;d have to make filters too). I also didn&#8217;t want to manage actually sending real email. So, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.smartlogicsolutions.com/wiki/John_Trupiano">John Trupiano</a> has <a href="http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/">a great post</a> to get you started with <a href="http://github.com/jtrupiano/sanitize_email/tree/master">sanitize_email</a> for Ruby on Rails.</p>
<p>I wanted to preview my HTML emails without having to fill up my online email inboxes with tons of email (and then I&#8217;d have to make filters too). I also didn&#8217;t want to manage actually sending real email. So, I set up my machine for local delivery. Read on for instructions.<br />
<span id="more-605"></span><br />
I am running Ubuntu 9.04, however these instructions should be fine at least back to 8.04.</p>
<h3>Step 1 &#8211; Install Postfix</h3>
<p><code>sudo aptitude install postfix</code></p>
<p>During the install, choose &#8220;Local Delivery Only&#8221;</p>
<h3>Step 2 &#8211; Configure Evolution for Receiving Locally</h3>
<p>Open up Evolution &#8220;Applications->Internet->Evolution Mail&#8221;</p>
<p>Set up a new account and choose local delivery. When it asks you for a path, put in:</p>
<p><code>/var/mail/&lt;username&gt;</code></p>
<p>Note that this path may not exist if you&#8217;ve never received mail.</p>
<h3>Step 3 &#8211; Configure Sanitize Email</h3>
<p>In your rails test environment.rb put:</p>
<p><code>config.action_mailer.delivery_method = :sendmail</code></p>
<p>Then, in the initializer where you set up sanitize email:</p>
<p><code>ActionMailer::Base.sanitized_recipients = ["<username>@<hostname>"]<br />
ActionMailer::Base.local_environments = %w( test )</code></p>
<p>If you need to know your username or hostname, just open up a terminal. The command &#8220;whoami&#8221; will give you your username, and &#8220;hostname&#8221; will give you the hostname.</p>
<h3>Step 4 &#8211; Run your tests</h3>
<p>Now, run your rails tests. You <em>should</em> have a test for every email you send, and that should trigger them to be sent locally. You may have to tell Evolution to Send/Receive. Keep in mind your tests will probably fail because they will expect email to be in test mode.</p>
<h3>Step 5 &#8211; Set it back</h3>
<p>Remember, when you&#8217;re done previewing your email, reset config.action_mailer.delivery_method!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/" rel="bookmark" class="crp_title">Reintroducing sanitize_email | Work with Production Email without Fear</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/02/better-setup-for-environments-in-rails/" rel="bookmark" class="crp_title">Better setup for environments in Rails</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/" rel="bookmark" class="crp_title">Setting Up Ubuntu 9.10 for Ruby On Rails Development</a></li><li><a href="http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/" rel="bookmark" class="crp_title">Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/" rel="bookmark" class="crp_title">Benchmark Ruby Code with R, rsruby and better-benchmark</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reintroducing sanitize_email &#124; Work with Production Email without Fear</title>
		<link>http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 15:27:43 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[John Trupiano]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=579</guid>
		<description><![CDATA[An issue I have to tackle on almost every project I encounter is developing, QA&#8217;ing, and troubleshooting email generated from my app. Rails provides a couple of options to help during the development and test phases (setting action_mailer.delivery_method = :test), but there aren&#8217;t any great mechanisms for performing QA with a client or troubleshooting production [...]]]></description>
			<content:encoded><![CDATA[<p>An issue I have to tackle on almost every project I encounter is developing, QA&#8217;ing, and troubleshooting email generated from my app.  Rails provides a couple of options to help during the development and test phases (setting action_mailer.delivery_method = :test), but there aren&#8217;t any great mechanisms for performing QA with a client or troubleshooting production email issues (formatting, content, etc).</p>
<p>Not long ago I stumbled upon <a href="http://galtzo.blogspot.com/2008/11/sanitize-email-never-worry-about.html">Peter Boling&#8217;s plugin implementation of sanitize_email</a>.  I&#8217;ve since forked it, turned it into a gem, and continued to apply maintenance commits to it as rails has marched forward through versions 2.2 and 2.3.  </p>
<p>The primary value <a href="http://johntrupiano.rubyforge.org/sanitize_email">sanitize_email</a> provides is that it allows you to reroute all email without having to alter any application code.  It&#8217;s environment-specific and doesn&#8217;t introduce any production/deployment dependencies.</p>
<p><span id="more-579"></span></p>
<h3>Installation</h3>
<p>To install, simply execute:<br />
<code></p>
<pre>
  $> sudo gem install sanitize_email
</pre>
<p></code></p>
<h3>Use Cases</h3>
<p>There are three primary use cases for sanitize_email.</p>
<h4>Working Locally with Production Data</h4>
<p>Scenario: you have a mechanism for recreating your production environment in your development environment (<a href="http://github.com/jtrupiano/capistrano-extensions">capistrano-extensions</a> provides this capability for MySQL databases).  You want to pull down the production data to troubleshoot a live email issue.  Using sanitize_email, we can set up our dev environment to override all email envelopes so that email actually goes to an inbox of your choice.</p>
<h4>Re-routing Email on a Staging or QA Server</h4>
<p>During initial development of a new email feature, it&#8217;s imperative that the client/stakeholder be able to review all emails being generated.  sanitize_email makes it dead simple to specify that your staging environment route all email generated to a specific email address without having to change any application code.</p>
<h4>Testing Email from a Hot Production Server</h4>
<p>You can install sanitize_email on your production server, and then utilize it from the console to give you more freedom when poking and prodding your application.  You can trigger any email you need to without fear that it will go to a real live email address.</p>
<h3>Sample Usage of sanitize_email</h3>
<p>sanitize_email uses ActionMailer::Base.local_environments to specify in which environments to override the SMTP envelope.  Note that a set of defaults can be configured in an initializer file, and then overridden in specific environment files for further control.</p>
<p><code></p>
<pre>
    # Settings for sanitize_email gem.  These can be overridden in individual config/%env%/environment.rb files.
    require 'sanitize_email'
    ActionMailer::Base.sanitized_recipients = "john@smartlogicsolutions.com"
    ActionMailer::Base.sanitized_bcc = nil
    ActionMailer::Base.sanitized_cc = nil

    # These are the environments whose outgoing email BCC, CC and recipients fields will be overridden!
    # All environments not listed will be treated as normal.
    ActionMailer::Base.local_environments = %w( development test staging )
</pre>
<p></code></p>
<h3>Closing Notes</h3>
<p>The functionality provided by sanitize_email is truly very basic, and admittedly a little static.  You can only set a single override for any given environment, which doesn&#8217;t lend itself to a QA/review team that consists of more than a single person.  I have been working on <a href="http://github.com/jtrupiano/rails-caddy">rails-caddy</a> which is a tool for bringing a lot of QA goodness to the browser.  One feature it provides is an integration with sanitize_email, allowing these overridden email addresses to be set on a per session basis, which in turn allows several individuals to work on a staging server at the same time and each receive the email that their own actions triggered.  It&#8217;s still in its early stages (pre 0.1.0 release), but it&#8217;s something we&#8217;re using on several apps already.</p>
<h3>Related Links</h3>
<p><a href="http://johntrupiano.rubyforge.org/sanitize_email">RDoc</a> | <a href="http://github.com/jtrupiano/sanitize_email">Source on GitHub</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/" rel="bookmark" class="crp_title">Using Sanitize Email to Preview HTML Emails Locally</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/02/better-setup-for-environments-in-rails/" rel="bookmark" class="crp_title">Better setup for environments in Rails</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/08/04/introducing-environmentalize-an-intuitive-environment-focused-config-structure-for-your-rails-applications/" rel="bookmark" class="crp_title">Introducing environmentalist: an intuitive, environment-focused config structure for your rails applications</a></li><li><a href="http://blog.smartlogicsolutions.com/2009/04/04/environmentalist-023-released-supports-rails-232/" rel="bookmark" class="crp_title">environmentalist 0.2.3 released &#8212; supports rails 2.3.2</a></li><li><a href="http://blog.smartlogicsolutions.com/2009/02/24/rails-23-nested-object-forms-im-not-crazy-about-them/" rel="bookmark" class="crp_title">Rails 2.3 Nested Object Forms: I&#8217;m not Crazy about Them</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

