Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8653891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:39:06+00:00 2026-06-12T14:39:06+00:00

I am having trouble with email synchronization application, i am developing an conversation module

  • 0

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

"--PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 Content-Type: text/plain --PHP-alt-9ce0b24f8d52c4d37de61cb315107795d140f8b7 "

and i want to remove it

actual output is

--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:

and i want something like

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:

i have tried substr() but its not that helpful
any regular expression may be?
here is code for email sending
lets assume body string = $email_message where all email format is written in “string”
PS: please note that some emails contains attachments

$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 <sender@gmail.com> \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 =<<<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
<strong>
Star Limousines<br/>
TEL: 0800 9 556 556 <br/>
or 01435 813494</strong><br/>
<span style="font-size:10px">Registerd Office Pick Hill Farm, Horam East Sussex TN21 0JR</span>

--PHP-mixed-{$sep}--
EOBODY;
$body=$email_message;

mail($to,$subject,$body);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:39:07+00:00Added an answer on June 12, 2026 at 2:39 pm

    At any point of time, the headers are in the first two lines right? If that’s the case, you can go with this:

    substr($email, strpos($email, PHP_EOL, strpos($email, PHP_EOL) + 1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble sending email using my gmail account. I'm pulling my hair out.
I got an email a few days ago from someone who was having trouble
I am having trouble sending email from my app at Google App Engine. I
I'm having trouble getting MVCMailer to delete attachments after sending an email asynchronously. I
I'm having trouble using the Email:MIME module in perl. It's probably because I'm using
as indicated by the title I am having trouble sending an email via my
I am having trouble sending the password of a user to his email. everthing
I'm having trouble with models disappearing after populating a Backbone collection from a url.
I'm having trouble sending mail using SMTP from a Rails app. I have a
I'm having trouble curling a backup from Heroku. I'm trying to use heroku add:keys

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.