I’m trying to parse an email which had the following lifecycle (dummy example):
Two days ago :
from : a@a.com
to : b@b.com
Subjet : Hello !
Yesterday :
from : b@b.com
to : a@a.com
Subjet : Re : Hello !
Today :
The mail is forwaded to c@c.com.
I have access to this mailbox and I’m able to retrieve the email via php and imap functions. I’m now able to parse the mail, and get the following informations:
from : a@a.com
to : c@c.com
Fwd : Re : Hello !
Is there anyway i can get the history of that email ? I would like to be able to display something like :
Mails history:
- From a@a.com to c@c.com – Fwd : Re : Hello ! -Today
- From b@b.com to a@a.com – Re: Hello ! – Yesterday
- From a@a.com to b@b.com – Hello ! – Two days ago
edit : to be more accurate, the only thing I really do need to get is what happend to the mail just before it was forwaded to c@c.com (in my example, sent from b@b.com to c@c.com). I do not really need to get what happend before.
I have searched on the Internet for a pretty long time, but since i’m not that fluent in English, I probably didn’t use the best query…
Thanks for your help !
Unless the information is contained in the mail itself, no.
You can look at the raw mail, including headers and raw body, to see what’s in the mail. If it’s not in there, and you don’t have access to the other accounts it went through first, then you can’t get the history of the message.
Messages can contain headers like this:
This is only really useful if you have access to the original messages referenced in these headers. If all you got is the last mail in the chain, this is not very useful.
Your best bet will be to look for quoted content inside the mail, like:
There’s no standardized format for these lines though, each email program inserts its own version, sometimes user customized, sometimes localized. So they’re hard to parse out reliably.