Is the Delivered-To header the right place to find the address of the recipient for forwarded mail?
There is a mail processing script on example.com that processes emails sent to addresses like: account1234@example.com
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 user1234@gmail.com to account1234@example.com then the processing script will find user1234@gmail.com in the To: header and account1234@example.com in the Delivered-To: header.
Is that Delivered-To: header guaranteed to be there or is this specific to the mail server doing t开发者_Python百科he forwarding?
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, a@example.com
forwards to b@sample.com
, which forwards back to a@example.com
.) Various servers use different header fields for this purpose, and there is no formal standard.
精彩评论