HostingMailcow

Self-hosted Mailcow, relaying through MXRoute

I self-host my emails using Mailcow. Inbound emails come directly to my server, but outbound emails are routed through MXRoute because their deliverability is much better than mine.

In Mailcow, set up your domains and mailboxes like normal. I assume you’ve already done this.

In MXRoute’s cPanel or DirectAdmin, create one account per domain.
Configure the account as a catchall for the domain. In cPanel, this is under Forwarders / Aliases → Add Domain Forwarder. Not sure where it is in DirectAdmin as I don’t have any DirectAdmin accounts to test with. The reason it needs to be a catchall is so it can be used to send mail from any address at the domain.

Set your MX record to your server (not MXRoute), and the SPF to both your server and MXRoute. Example SPF:

 
v=spf1 ip4:198.51.100.1 ip6:2001:db8::1 include:mxroute.com -all

where 198.51.100.1 and 2001:db8::1 are your server’s IPs. You can use mx instead of specifying the IPs, but that adds an extra DNS lookup, and SPF records fail if there are too many DNS lookups required.

If you use DKIM/DomainKeys, configure it for both your server and MXRoute, using different selectors for each. Details about how to configure this are outside the scope of this post.

In Mailcow, go to Configuration (in the top menu) → Configuration & Details → Routing tab.

 

 

Enter a from address at your domain, leave the to address as null@hosted.mailcow.de, and ensure it works (you get a 250 OK at the end):

 

 

Now send an email through webmail or your email client, and see if it works. :smile:

These instructions show Mailcow since that’s what I use, however it uses a standard Postfix feature called sender_dependent_relayhost_maps, so you can do the same thing through other systems like Mail-in-a-box or by directly modifying the Postfix config.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button