remove response body from imap email

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm using php's native imap functions to pull emails from an imap
server.  I have access to individual headers, mail body, and mime
attachments where present.  My script is handling user responses to a
message the system sends them.  The problem is their incoming messages
almost always contain the original message at the end of the email's
main body, and depending on what mail client they reply with it is
usually slightly different.

Does anyone have any creative solutions for stripping out this
response body text from the end of the email?

Re: remove response body from imap email

Quoted text here. Click to load it

This is probably not the best way of doing it but you could use:

$message body = "Content, Content, Content, blah blah
----- original message ---
Subject: etc, etc

$message = explode('----- original message ---', $message_body);

echo $message[0];

Re: remove response body from imap email

Yup, unforunately only some email clients use "----- original message
---" as their delimiter.  Seems everyone is a little different.

Gmail handles this well, and is always able to delineate and hide the
response text.  Maybe they have a database of all possible delimiters
and a 1000 line regex.

On Mar 16, 4:02=A0pm, ""
Quoted text here. Click to load it

Site Timeline