title: PHP's mail() function messes up HTML in email message
body: <p>So I have the following code. It's supposed to send HTML emails that were edited in the precedent screen. However, once the email is sent, in html tags, the first double quote and letter of each tag go missing, for instance, </p>
  
  <pre><code>&lt;span style="something"&gt;
  </code></pre>
  
  <p>becomes </p>
  
  <pre><code>&lt;span style=omething"&gt;
  </code></pre>
  
  <p>The odd part is, the message is printed fine if echoed to the screen, so I don't think it has anything to do with how it's being sent to the whole function, but how it's being sent to the mail() function...but I have no clue what the issue could be. Here is the code, without all the getting of variables and such because i don't think it's particularly relevant.</p>
  
  <pre><code>//start of the headers
  $headers = "From: $from_name&lt;$from_email&gt;\n";
  $headers .= "Reply-To: &lt;$reply_to&gt;\n"; 
  $headers .= "MIME-Version: 1.0\n";
  $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
  $headers .= "X-Sender: $from_name&lt;$from_email&gt;\n";
  $headers .= "X-Mailer: PHP4\n";
  $headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
  $headers .= "Return-Path: &lt;$from_email&gt;\n"; 
  $headers .= "This is a multi-part message in MIME format.\n";
  $headers .= "------=MIME_BOUNDRY_main_message \n"; 
  $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n"; 
  
  $message = "------=MIME_BOUNDRY_message_parts\n";
  $message .= "Content-Type: text/html\r\n";  //changed to support html
  $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
  $message .= "\n"; 
  /* note: add HTML by changing the Content-Type to text/html */
  ////TEST 1 - this is where i attempted to hardcode some code in to see if it would send properly: it wouldn't. printed fine though.
  $message .="&lt;font class=\"Apple-style-span\" face=\"'Courier New'\" size=\"5\"&gt;\n"; 
  $message .= "bbbbb&lt;b&gt;bbbb&lt;i&gt;bbb&lt;u&gt;bbb&lt;font class=\"Apple-style-span\" color=\"#000099\"&gt;\n"; 
  $message .= "bbbbb&lt;span class=\"Apple-style-span\" style=\"background-color: rgb(102, 255, 204);\"&gt;bbbbbb&lt;/span&gt;&lt;/font&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;\n";
  /////end test 1
  $message .= $body.'\n';
  $message .= "\n\n"; 
  $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
  if($file_present==1){ // added this to fix empty file bug
  $message .= "\n"; 
  $message .= "------=MIME_BOUNDRY_main_message\n"; 
  $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
  $message .= "Content-Transfer-Encoding: base64\n";
  $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
  $message .= $data; //The base64 encoded message 
  $message .= "\n"; 
  $message .= "------=MIME_BOUNDRY_main_message--\n"; 
  }
  echo $message; //this is where it echoes fine, with all tags intact
  // send the message
     if( mail("$to_name&lt;$to_email&gt;", $subject, $message, $headers)){ //this is where it goes wrong.
       echo("&lt;p&gt;Message successfully sent to ".$to_email.".&lt;/p&gt;");
    } else {
     echo("&lt;p&gt;Message delivery to ".$to_email." failed.&lt;/p&gt;");
    }
  </code></pre>