<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: CRLF, PHP, Postfix, and SPAM</title>
	<link>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/</link>
	<description></description>
	<pubDate>Thu, 09 Sep 2010 06:43:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: The Doctor What</title>
		<link>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2445</link>
		<author>The Doctor What</author>
		<pubDate>Sat, 27 Oct 2007 00:08:52 +0000</pubDate>
		<guid>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2445</guid>
		<description>Okay, now that makes sense.

Your mistake was ... using mail in PHP.

It's not a good thing, it's not portable, it won't let you efficiently
send emails to multiple people, etc. etc.

One of the first things I had to do at RackSpace was write a
replacement mail library in PHP.  I tried to make it work using the
mail command, but it offers no protection, no guarantees, etc.  I
wrote a semi-lame one that worked for a couple years.

In the end, I wrote it in two parts:
1) It queued the email in a table.
2) It used port 25 to send it to a known good SMTP server in-house and
   would only then delete the email from the table.

A future version was going to keep the emails for a while and to match
up bounced emails for tagging later instead of having humans do
that...

I think now there are some good mail libraries, like &lt;a href="http://phpmailer.sourceforge.net/" rel="nofollow"&gt;PHPMailer&lt;/a&gt; that can take a
lot of the pain out of mailing in PHP.

Ciao!</description>
		<content:encoded><![CDATA[<p>Okay, now that makes sense.</p>
<p>Your mistake was &#8230; using mail in PHP.</p>
<p>It&#8217;s not a good thing, it&#8217;s not portable, it won&#8217;t let you efficiently<br />
send emails to multiple people, etc. etc.</p>
<p>One of the first things I had to do at RackSpace was write a<br />
replacement mail library in PHP.  I tried to make it work using the<br />
mail command, but it offers no protection, no guarantees, etc.  I<br />
wrote a semi-lame one that worked for a couple years.</p>
<p>In the end, I wrote it in two parts:<br />
1) It queued the email in a table.<br />
2) It used port 25 to send it to a known good SMTP server in-house and<br />
   would only then delete the email from the table.</p>
<p>A future version was going to keep the emails for a while and to match<br />
up bounced emails for tagging later instead of having humans do<br />
that&#8230;</p>
<p>I think now there are some good mail libraries, like <a href="http://phpmailer.sourceforge.net/" rel="nofollow">PHPMailer</a> that can take a<br />
lot of the pain out of mailing in PHP.</p>
<p>Ciao!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Mills</title>
		<link>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2397</link>
		<author>Bryan Mills</author>
		<pubDate>Thu, 25 Oct 2007 00:24:39 +0000</pubDate>
		<guid>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2397</guid>
		<description>I just realized that I never mentioned that this only happens when I send emails through the php built-in function mail.  Below is copied from a posting on a php mailing list (also found here: http://us3.php.net/function.mail).

-----------------
Note that there is a big difference between the behavior of this function on Windows systems vs. UNIX systems. On Windows it delivers directly to an SMTP server, while on a UNIX system it uses a local command to hand off to the system's own MTA.

The upshot of all this is that on a Windows system your  message and headers must use the standard line endings \r\n as prescribed by the email specs. On a UNIX system the MTA's "sendmail" interface assumes that recieved data will use UNIX line endings and will turn any \n to \r\n, so you must supply only \n to mail() on a UNIX system to avoid the MTA hypercorrecting to \r\r\n.

If you use plain old \n on a Windows system, some MTAs will get a little upset. qmail in particular will refuse outright to accept any message that has a lonely \n without an accompanying \r.</description>
		<content:encoded><![CDATA[<p>I just realized that I never mentioned that this only happens when I send emails through the php built-in function mail.  Below is copied from a posting on a php mailing list (also found here: <a href="http://us3.php.net/function.mail" rel="nofollow">http://us3.php.net/function.mail</a>).</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Note that there is a big difference between the behavior of this function on Windows systems vs. UNIX systems. On Windows it delivers directly to an SMTP server, while on a UNIX system it uses a local command to hand off to the system&#8217;s own MTA.</p>
<p>The upshot of all this is that on a Windows system your  message and headers must use the standard line endings \r\n as prescribed by the email specs. On a UNIX system the MTA&#8217;s &#8220;sendmail&#8221; interface assumes that recieved data will use UNIX line endings and will turn any \n to \r\n, so you must supply only \n to mail() on a UNIX system to avoid the MTA hypercorrecting to \r\r\n.</p>
<p>If you use plain old \n on a Windows system, some MTAs will get a little upset. qmail in particular will refuse outright to accept any message that has a lonely \n without an accompanying \r.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Doctor What</title>
		<link>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2379</link>
		<author>The Doctor What</author>
		<pubDate>Tue, 23 Oct 2007 22:50:07 +0000</pubDate>
		<guid>http://www.bryanmills.net/archives/2007/10/crlf-php-and-spam/#comment-2379</guid>
		<description>Something doesn't add up.  Postfix does nothing of the sort to incoming emails.

Are you passing the email to postfix directly via the command-line?

What does PHP have to do with this?

Ciao!</description>
		<content:encoded><![CDATA[<p>Something doesn&#8217;t add up.  Postfix does nothing of the sort to incoming emails.</p>
<p>Are you passing the email to postfix directly via the command-line?</p>
<p>What does PHP have to do with this?</p>
<p>Ciao!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
