I am writing a program that polls an incoming mailbox (to which anyone who knows about it can post), reformats the info, then forwards the mail on to the correct address according to a predefined convention. For example, the incoming mail has:
From = "anybody@somedomain.com"
To = "myincomingmailbox@mydomain.com"
Subject = "Subject"
Body = "recipient@anotherdomain.com+newline+Body"
Then I take that email, preserve the "From" and "Subject" fields, but I change the "To" address to recipient@anotherdomain.com
, and format the rest of the body according to my template.
Thus far all OK - but I anticipate a problem with spam filters on the recipient domains, since they may react as if I'm spoofing the "From" address.
What is the correct way to preserve the headers from the original mail intact, such that all the SPF/DKIM headers remain on the outgoing email, and the recipient domains don't treat the incoming mail as possible spam/phishing mails?