简体   繁体   中英

how to extract replied email from original email

I am using imap to grap emails and insert them into a mysql database. But I don't want the original email included.

So lets say I send out an email that contains this: Hello, How is the weather.

And then you respond The weather is great

The email that php reads from Imap looks like this: The weather is great Hello, How is the weather.

Is there away to remove the orginal message, "Hello, How is the weather."?

I am not to savvy on this stuff and will probably need things explained very clearly. Thanks!

Nope. Since there is no standard way to reply (ie, some people use >, some use |, some top-post, some intermix, some attach) there's no way to accurately and reliably pull out the original. You could fiddle with regexp to catch some of the more common cases, but I think you'll find that route to be far more trouble than it's worth.

To my knowledge, there is no foolproof way to do this. When you reply to an email, the MUA has the right to reformat the original message as it sees fit. For example, Outlook may convert the original text to HTML and add invisible tags.

If you have access to the whole email thread, you may be able to find the original message based on subject or any hints that the headers give you.

This is all AFAIK, so someone please correct me if I am wrong.

You could do what Gmail does when you are sending multiple emails back and forth with the same subject.

Just keep a copy of the email that you send and then when you get a reply, look for similar text or as Gmail refers to it: "quoted text".

Or you can look for certain patterns based on their email domain. However, there is no answer that will work 100% of the time; it is all just based on your best guess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM