title: gmail does not render html in email
body: <p>I am going to try this one more time with a very basic example. When I send an e-mail using PHP to e-mail clients, I have no problem except with gmail. When I view the e-mail in gmail, all I see is the code of the message. Gmail does not display the HTML. It just displays the code. Here is my script:</p>
  
  <pre><code>&lt;?php
  $to = "someone@gmail.com";
  $subject = "Test HTML E-mail";
  $random_hash = md5(date("r", time()));
  $mID = md5($to);
  $headers = "From: admin@yellowcas.com" . "\n" . "Reply-To: admin@yellowcas.com" . "\n";
  $headers .= "Errors-To: someone@yahoo.com" . "\n";
  $headers .= "MIME-Version: 1.0" . "\n";
  $headers .= "Content-Type: multipart/alternative; boundary=". $random_hash ." ; Message-ID: &lt;" . $mID . "&gt;" . "\n"; 
  ob_start();
  ?&gt;
  --&lt;?php echo $random_hash; ?&gt; 
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  Hello, Tom!!! 
  This is simple text email message.
  
  --&lt;?php echo $random_hash; ?&gt; 
  Content-Type: text/html; charset=utf-8
  Content-Transfer-Encoding: 7bit
  
  &lt;!doctype html&gt;
  &lt;head&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Hello, Tom!&lt;/h2&gt;
  &lt;p&gt;This is something with &lt;strong&gt;HTML&lt;/strong&gt; formatting.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  --&lt;?php echo $random_hash; ?&gt;-- 
  
  &lt;?php
  $message = ob_get_clean();
  $mail_sent = @mail( $to, $subject, $message, $headers );
  echo $mail_sent ? "Mail sent" : "Mail failed";
  ?&gt;
  </code></pre>
  
  <p>I have tried this script without the DOCTYPE and with the DOCTYPE. I do not believe there is anything wrong with the HTML. I believe gmail is not recognizing the boundary string for some reason. Here is what I see when I open the e-mail:</p>
  
  <pre><code>--111f3d21df6a6eb40a42e9337a600c21
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  Hello, Tom!!!
  This is simple text email message.
  
  --111f3d21df6a6eb40a42e9337a600c21
  Content-Type: text/html; charset=utf-8
  Content-Transfer-Encoding: 7bit
  
  &lt;!doctype html&gt;
  &lt;head&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Hello, Tom!&lt;/h2&gt;
  &lt;p&gt;This is something with &lt;strong&gt;HTML&lt;/strong&gt; formatting.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  --111f3d21df6a6eb40a42e9337a600c21--
  </code></pre>
  
  <p>Can anyone <strong>PLEASE</strong> tell me why gmail is rendering the whole message and not encoding the HTML? It is as if gmail does not recognize the boundary string. How do I fix this?</p>
  
  <p>As a side note, yes, this is a basic PHP e-mail script I found on the internet. I have made a few modifications, but it is still not working in gmail. All other e-mail clients render it fine. <strong>PLEASE HELP!</strong> I am at my wit's end. Thank you.</p>
  
  <p>When I added the $headers line in the code example right below that was submitted by Fred -ii-, gmail rendered the HTML, but it still shows the boundary string and the plain text message also. This is what the e-mail looks like:</p>
  
  <blockquote>--f8451c07b6649388e8938cfa12ea21e6 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Hello, Greg!!! This is simple text email message. --f8451c07b6649388e8938cfa12ea21e6 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 7bit
  <h2>Hello, Tom!</h2>
  
  This is something with <strong>HTML</strong> formatting.
  
  --f8451c07b6649388e8938cfa12ea21e6-- 
  </blockquote>
  
  <p>I hope that comes out right.</p>