title: PHP mail formatting issue - Why do CRLF header line endings break HTML email in Outlook?
body: <p>I'm using the PHP native <code>mail()</code> function to send HTML emails and have a formatting problem in the users most common email client - <strong>Outlook 2007</strong> (<em>in addition to some other email clients</em>) - all the html tags are exposed so it looks like gibberish to a non-web-developer.</p>
  
  <p>I'm sending HTML email the same way that the <a href="http://php.net/manual/en/function.mail.php" rel="nofollow noreferrer">PHP manual</a> demos it. Example:</p>
  
  <pre><code>$message  = get_HTML_email_with_valid_formatting();
  $headers  = "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  $headers .= "From: example.com &lt;info@example.com&gt;\r\n";
  $headers .= "Reply-To: donotreply@example.com\r\n";
  mail('me@example.com', 'test', $message, $headers);
  </code></pre>
  
  <p>Because testing various email clients is hard, I have signed up with <a href="http://litmusapp.com/" rel="nofollow noreferrer">http://litmusapp.com/</a> so I can see a screenshot of the emails in 47 different email clients. Most are ok (e.g. gmail, thunderbird, Lotus Notes) but all the different versions of Outlook are not ok.</p>
  
  <p>To fix the formatting issue I had do the following:</p>
  
  <ol>
  <li>Remove the <code>$headers  = "MIME-Version: 1.0\r\n";</code> mail header. </li>
  <li>Ensure I end my headers with only "<code>\n</code>" instead of "<code>\r\n</code>".</li>
  </ol>
  
  <p>Does anyone know why I am getting better results with HTML emails when I do not conform to the manual?</p>
  
  <p>Info:</p>
  
  <ul>
  <li>I'm using <a href="http://www.postfix.org/" rel="nofollow noreferrer">postfix</a> version 2.3.3 on RHEL 5.5.</li>
  <li>PHP version 5.3.2</li>
  </ul>