title: Remove headers from Email Body
body: <p>I am having trouble with email synchronization application, i am developing an conversation module for my project so i had extracted email body and attachments from the Email Account but problem is i also got some header text in email body like </p>
  
  <pre><code>"--PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 Content-Type: text/plain --PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 "
  </code></pre>
  
  <p>and i want to remove it</p>
  
  <p>actual output is</p>
  
  <pre><code>--PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 Content-Type: text/plain --PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 Content-Type: multipart/related; boundary="PHP-related-9ce0b24f8d52c4d37de61cb315107795d140f8b7" --PHP-related-9ce0b24f8d52c4d37de61cb315107795d140f8b7 Content-Type: text/html Dear Milind
  
  Thank you for choosing XXXXX for your limo hire.
  
  Please accept this e-mail as confirmation the following booking has been
  confirmed and requires you to print, sign and return the attached
  contract with us, either by e-mail, fax or post, within 3 days.
  To view contract for booking please click here
  We would like to draw your attention to our agreed Terms and
  Conditions concerning the booking and ask that you ensure you comply,
  which can be found on our website www.xxxxx.co.uk
  
  If this has been received in error, please contact our Office
  immediately on XXXXXXX or XXXXXX.
  
  Regards
  Company name
  TEL:
  </code></pre>
  
  <p>and i want something like </p>
  
  <pre><code>Dear Milind
  
      Thank you for choosing XXXXX for your limo hire.
  
      Please accept this e-mail as confirmation the following booking has been
      confirmed and requires you to print, sign and return the attached
      contract with us, either by e-mail, fax or post, within 3 days.
      To view contract for booking please click here
      We would like to draw your attention to our agreed Terms and
      Conditions concerning the booking and ask that you ensure you comply,
      which can be found on our website www.xxxxx.co.uk
  
      If this has been received in error, please contact our Office
      immediately on XXXXXXX or XXXXXX.
  
      Regards
      Company name
      TEL:
  </code></pre>
  
  <p>i have tried <code>substr()</code> but its not that helpful
  any regular expression may be?
  here is code for email sending
  lets assume body string = <code>$email_message</code> where all email format is written in "string"
  PS: please note that some emails contains attachments</p>
  
  <pre><code>$subject = 'A sample email - Dual Format plus attachment plus inline';
  
  // Create a boundary string.  It needs to be unique (not in the text) so ...
  // We are going to use the sha1 algorithm to generate a 40 character string:
  $sep = sha1(date('r', time()));
  
  // Define the headers we want passed.
  $headers = "From: StarLimosine &lt;sender@gmail.com&gt; \r\n X-Mailer: Custom PHP Script";
  //$headers.="\r\nCc:sender@gmail.com";
  $headers.="\r\nBcc:sender@gmail.com , sender@gmail.in";
  // Add in our primary content boundary, and mime type specification:
  $headers .= 
      "\r\nContent-Type: text/html; boundary=\"PHP-mixed-{$sep}\"";
  
  // Prepare our attachment file - Read it in, encode it and split it
  //$attached = chunk_split(base64_encode(file_get_contents('attachment.zip')));
  
  // Also now prepare our inline image - Also read, encode, split:
  $inline = chunk_split(base64_encode(file_get_contents('images/Logo.png')));
  
  // Now the body of the message.
  $body =&lt;&lt;&lt;EOBODY
  --PHP-mixed-{$sep}
  Content-Type: multipart/alternative; boundary="PHP-alt-{$sep}"
  
  --PHP-alt-{$sep}
  Content-Type: text/plain
  
  
  --PHP-alt-{$sep}
  Content-Type: multipart/related; boundary="PHP-related-{$sep}"
  
  --PHP-related-{$sep}
  Content-Type: text/html
  
  $email_message
  &lt;strong&gt;
  Star Limousines&lt;br/&gt;
  TEL: 0800 9 556 556 &lt;br/&gt;
  or 01435 813494&lt;/strong&gt;&lt;br/&gt;
  &lt;span style="font-size:10px"&gt;Registerd Office Pick Hill Farm, Horam East Sussex TN21 0JR&lt;/span&gt;
  
  --PHP-mixed-{$sep}--
  EOBODY;
  $body=$email_message;
  
  mail($to,$subject,$body);
  </code></pre>