This PHP Mime Mail Parser library is very useful:
https://github.com/php-mime-mail-parser/php-mime-mail-parser
Example request:
$arrayHeaderTo = $parser->getAddresses('to');
It lets you analyze the intended recipient, sender, subject, etc., of an email message in RFC822 standards format.
For those like me that are even more curious about an email message, such as which mailserver originated the message, I'd like to extend the library to have a dependable way to print this value, regardless of how it's found in the headers.
https://toolbox.googleapps.com/apps/messageheader/analyzeheader
Google provides a tool for analyzing message headers. I pasted an example here:
In this example, it would extract that complete server address ( ec2-54-245-11-255.us-west-2.compute.amazonaws.com ), and if possible, that server's IP, too. Assuming a good deal of these two values (mailserver, mailserverIP) are going to be spoofed, I would still like to see the values that are included in the header, dependably, regardless of how that header is structured, or wherein they appear.
So I guess this is a question for those who are very familiar with email headers, and a solid way to read them to extract this information.