11
votes

There is a mail processing script on example.com that processes emails sent to addresses like: [email protected]

The mail server has a catch-all for example.com and processes the email into the appropriate account.

For users who have setup up a forwarding rule from another email address I'm having trouble finding the right header to check for the account. For example if the user with account1234 has a gmail rule that forwards certain emails sent to [email protected] to [email protected] then the processing script will find [email protected] in the To: header and [email protected] in the Delivered-To: header.

Is that Delivered-To: header guaranteed to be there or is this specific to the mail server doing the forwarding?

1

1 Answers

13
votes

Unfortunately, it's specific to the host doing the forwarding. And it's not even there for your benefit -- it's there to allow the forwarding server to detect and break mail loops. (For instance, [email protected] forwards to [email protected], which forwards back to [email protected].) Various servers use different header fields for this purpose, and there is no formal standard.