Is it possible to get the original headers from a redirected email in php

I am trying to parse an email that has the following life cycle (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 :

Mail is sent to the address c@c.com. I have access to this mailbox and I can receive an email using the php and imap functions. Now I can parse the mail and get the following information:

from: a@a.com

to: c@c.com

Fwd: Re: Hello!

Anyway, can I get the history of this letter? I would like to be able to display something like:

History of letters:

  • 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

to change . To be more precise, the only thing I really need to get is what happened to the mail before it was rewritten to c@c.com (in my example, sent from b@b.com - c@c.com ) . I really don't need to get what I used to.

I searched the Internet for quite some time, but since I am not so fluent in English, I probably did not use the best query ...

Thanks for your help!

+6
source share
1 answer

If the information is not contained in the mail itself, no.

You can look at raw mail, including headers and raw body, to find out what is in the mail. If it is not there and you do not have access to other accounts, it went through first, then you cannot get the message history.

Messages may contain headers like this:

Message-Id: < 6F995D33-8CF3-4F49-AA6A-9D59B4779CCE@example.com > In-Reply-To: < 795EDCA1-7FD4-429C-88E9-26A85C442A5B@example.com > References: < b2hxc23ycjm05kradmfswofk.1332762974483@email.example.com > < D37FF604-43A2-42F8-AD11-2F2012D2E8B7@example.com > < 795EDCA1-7FD4-429C-88E9-26A85C442A5B@example.com > 

This is really useful if you have access to the original messages listed in these headers. If you received the last message in the thread, this is not very useful.

It will be best to search for quoted content inside the mail, for example:

 > On 2012/03/24, b@b.com wrote: > ... >> On 2012/03/23, a@a.com wrote: >> ... 

There is no standardized format for these lines, although each email program inserts its own version, sometimes a user preference, sometimes localized. Therefore, it is difficult to disassemble them reliably.

+5
source

Source: https://habr.com/ru/post/911672/


All Articles