<?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>Jetpack Flight Log &#187; sendmail</title>
	<atom:link href="http://jetpackweb.com/blog/tags/sendmail/feed/" rel="self" type="application/rss+xml" />
	<link>http://jetpackweb.com/blog</link>
	<description>Rock{et}ing the interweb</description>
	<lastBuildDate>Sun, 12 Jun 2011 17:51:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Override PHP&#8217;s mail() function during development</title>
		<link>http://jetpackweb.com/blog/2009/07/18/override-phps-mail-function-during-development/</link>
		<comments>http://jetpackweb.com/blog/2009/07/18/override-phps-mail-function-during-development/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 17:20:23 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[sendmail]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=59</guid>
		<description><![CDATA[When doing local development we generally don&#8217;t want our test servers sending out mail to the world. And it would be ideal to be able to review the emails our application does send out before deploying the changes to the world. An easy way to achieve this functionality is to override PHP&#8217;s sendmail_path config variable. [...]]]></description>
			<content:encoded><![CDATA[<p>When doing local development we generally don&#8217;t want our test servers sending out mail to the world. And it would be ideal to be able to review the emails our application does send out before deploying the changes to the world. An easy way to achieve this functionality is to override PHP&#8217;s sendmail_path config variable. First lets install a few packegs that will allow us to send mail, and some useful scripts to rewrite the mail:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">sudo</span> <span class="kw2">apt-get</span> <span class="kw2">install</span> <span class="kw2">procmail</span> <span class="kw2">sendmail</span></pre></div></div>

<p>Next create the following script that will rewrite any mail that all mail generated by PHP&#8217;s mail() function to the local user of your choice:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">vi</span> <span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>bin<span class="sy0">/</span>trapmail</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash">formail <span class="re5">-R</span> <span class="kw2">cc</span> X-original-cc \
<span class="re5">-R</span> to X-original-to \
<span class="re5">-R</span> bcc X-original-bcc \
<span class="re5">-f</span> <span class="re5">-A</span><span class="st0">&quot;To: username@localhost&quot;</span> \
<span class="sy0">|</span> <span class="sy0">/</span>usr<span class="sy0">/</span>sbin<span class="sy0">/</span><span class="kw2">sendmail</span> <span class="re5">-t</span> <span class="re5">-i</span></pre></div></div>

<p>Replace <i>username@localhost</i> with your local username or an external email address.</p>
<p>Now update your php.ini file&#8217;s sendmail_path:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">grep</span> sendmail_path <span class="sy0">/</span>etc<span class="sy0">/</span>php5<span class="sy0">/</span>apache2<span class="sy0">/</span>conf<span class="sy0">/</span>php.ini
&nbsp;
<span class="re2">sendmail_path</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>bin<span class="sy0">/</span>trapmail</pre></div></div>

<p>You can then use mail client like mutt or Thunderbird to review the emails, or just tail your mbox file.</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2009/07/18/override-phps-mail-function-during-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

