I had email source with me and want parse original recipient of email.
Lets say "user1@test.com" is receiving a email, but in "To" list user1@test.com, user2@test.com & user3@test.com are mentioned. I want to get only user1 from email source.
In initial analysis, email from mdeamon server contains "X-MDaemon-Deliver-To:" tag. Similarly email from Devcot mail server contains "Delivered-To:". But not getting generic parsing logic to get original email recipient.
How I can parse email to get original recipient of an email?
The best way to get this information is probably to parse the Received
headers to see who the message was delivered for. In other words, look for a Received
header that has a for
token followed by x@x.com
(where x@x.com
will be the recipient).