title: PHP mail() Multipart/Alternative for HTML & Plain Text Emails
body: <p>I am using the following code to send out a Multipart/Alternative HTML and Plain Text email.  The emails are sending fine content wise, however some of them are getting caught in spam filters.  This is the code I am using.</p>
  
  <pre><code>$notice_text = "This is a multi-part message in MIME format.";
  $plain_text = "Some Plain Text Here\n\n";
  $html_text = '&lt;html&gt;&lt;head&gt;&lt;title&gt;Sample HTML Email&lt;/title&gt;&lt;/head&gt;&lt;body&gt;';
  $html_text .= '&lt;p&gt;Some text will go here.&lt;/p&gt;';
  $html_text .= '&lt;p&gt;&lt;img src="http://www.mydomain.com/img/offers.jpg" /&gt;&lt;/p&gt;';
  $html_text .= '&lt;p&gt;Can\'t see the images? &lt;a href="http://www.mydomain.com/print_offer.php?promo=' . $promo_code . '"&gt;Click here&lt;/a&gt;&lt;/p&gt;';
  $html_text .= '&lt;/body&gt;&lt;/html&gt;';
  
  $semi_rand = md5(time());
  $mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
  $mime_boundary_header = chr(34) . $mime_boundary . chr(34);
  
  $from = "Test Email &lt;testemail@testemail.com&gt;";
  $subject = "Get Your Offers Here";
  
  $body = "$notice_text
  
  --$mime_boundary
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  $plain_text
  
  --$mime_boundary
  Content-Type: text/html; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  $html_text
  
  --$mime_boundary--";
  
  mail($email, $subject, $body,
      "From: " . $from . "\n" .
      "bcc: " . $bcc . "\n" .
      "MIME-Version: 1.0\n" .
      "Content-Type: multipart/alternative;\n" .
      "     boundary=" . $mime_boundary_header);
  </code></pre>
  
  <p>What is causing it to go into spam filters?  When I send the email as a plain text they go through just fine, it is only when I send the HTML email that they are getting caught.  Any help would be appreciated.  Is there more I can add to the headers to help with spam filter prevention?</p>