Score:0

Forwarding emails while keeping From header intact

cn flag

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?

anx avatar
fr flag
anx
Yes, hosting your own mail, even just relaying, is complicated these days. No, it is just *some* popular cloud hosters choosing to break (at least in default configuration) some email use case. Which, btw, many admins thank them for because they had absolutely no handle on unsolicited mail before that.
anx avatar
fr flag
anx
The feasibility of relaying (unchanged) mail through your servers could depend on all senders properly DKIM-signing their mail, so that the final recipient can verify their authenticity. That is common, but not universal. Carefully reconsider the necessity of unconditionally keeping the original From header after clarifying who will be authorized to post to your distribution lists. And then still consider whether you want to do this yourself, or whether your use case is close enough to either features of the senders email program, or commercial mailing list provider offers.
Paul avatar
cn flag
While nearly all ISPs block TCP destination port 25 when your server is the source, most of those ISPs will have a policy of removing the block with a support ticket. They may have different requirements, such as age of the domain that resolves to the IP address, length of time you have done business with them, jurisdiction, etc., so you should ask them what their policy is, and with that you can configure Postfix or other MTA to perform as desired.
Rafal avatar
cn flag
@anx, true, I figure I'd need to sign the email myself, too. To be honest, current pricing for the hosting is not high (~15 USD/year) but since I'm going to need some small VPS I figured I could host that mailing feature there, too.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.