问题
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: AANLkTimYRxMJwjLSdcDP5ksM=xxx@mail.gmail.com
Reply ID: 20110316205225.xxx@example.com
Subject: Re: MessageX
To: q1-1234567890@example.com
From: Someone someone@someothersite.com
Body: Hello,
Blah Blah Blah
-Someone
On Wed, Mar 16, 2011 at 3:52 PM, <q1-1234567890@example.com> 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.
回答1:
This might be doable with a regular expression. Try:
$text = preg_replace('#(^\w.+:\n)?(^>.*(\n|$))+#mi', "", $text);
来源:https://stackoverflow.com/questions/5332382/php-filtering-email-body-removing-reply-quotes