mail-mime-parser
mail-mime-parser copied to clipboard
Getter for the "Received" header "for" part
Hi!
I wonder if it would be possible to have a getter to obtain the "for" part of the "Received" header, parsed and processed maybe as an AddressPart, or maybe as just an email.
I'm implementing some kind of receiving email application in AWS SES, and this is the only header I can rely to get the actual real recipient.
As of now, I'm using the follwing code to retrieve it:
/** @var ReceivedHeader $received */
$received = $mail->getHeader(HeaderConsts::RECEIVED);
$recipient = trim($received?->getValueFor('for') ?? '', '<>');
But as you can see, I have to, at least, trim the < and >.
So I wonder if the library could do it for us. Not just the trim, but every other parsing or post-processing that an email address may need.
Thanks!