I'm working on an email piping script that needs to save just the reply content and not the original quoted email. I'm using a mime parser class (http://www.phpclasses.org/package/3169-PHP-Decode-MIME-e-mail-messages.html) to get all the information that I need from the email:
Message ID: [email protected]
Reply ID: [email protected]
Subject: Re: MessageX
To: [email protected]
From: Someone [email protected]
Body: Hello,
Blah Blah Blah
-Someone
On Wed, Mar 16, 2011 at 3:52 PM, <[email protected]> wrote:
> Hello,
>
> Some other blah, blah, blah.
>
> Thank you,
> Me
In the body section, I'm getting the original quoted email. How can I filter this out? I know email clients often add ">" next to quoted content, but I'm not sure if this would be good enough. Thanks for your help.
This might be doable with a regular expression. Try:
$text = preg_replace('#(^\w.+:\n)?(^>.*(\n|$))+#mi', "", $text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With