What I want to achieve is mails sent to a specific user on my domain get forwarded to "subscribed" addresses I manage while preserving sender information and extending that with forwarding information, ie.:
[email protected] -> [email protected], [email protected]
[email protected] -> [email protected]
Mail sent from [email protected]
to [email protected]
should appear in my inbox as coming from [email protected]
destined to [email protected]
and sent through mydomain.com
. This is how my current hosting provider works, see this screenshot (edited) from my personal GMail mailbox.
I thought that this would be a relatively simple task:
- take some mail server software, eg.
postfix
- configure it to relay mails targeting specific users
- configure it to reject all other emails
- modify MX DNS entry of my domain to point to my mail server (eg.
mail.mydomain.com
)
However, it looks like mailing is crazy. Configuring mail servers aside but all cloud providers seem to block outgoing connections to TCP 25 so although I get connections from other mail servers to mail.mydomain.com
, my mail server cannot contact other mail servers thus it cannot forward emails. This can be worked around by using some 3rd party authenticated SMTP relay (ie. Amazon SES, Mailjet, etc), to have my mail server send emails through it. There are some limitations though, in case of Amazon SES I tried, the From:
header must be an address (or domain) that I verify, so I must rewrite it as the email is received. This option does not meet my requirements.
Is there some other approach to achieve what I want?