Postfix Settings

This is my setup:

Ubuntu 18.04 VPS running Apache virtual hosts using a combination of shared and dedicated IP addresses. I use the terminal for everything, there is no cPanel or other GUI used for configuration.

I have setup my DNS with the MX records as instructions here and everything seems to be working fine. I’ve tested mail from multiple domains with and everything is reporting good.

DIG shows:
dig MX +short mydomain1,com
10 echo,mxrouting,net
20 echo-relay,mxrouting,net

Seems like my outgoing SMTP mail is working as I can send mail via telnet 25 and using echo “This is a test email” | mail -s “Subject line”

I need to send outgoing automated transactional email from my VPS via mydomain1,com and mydomain2,com, such as invoices to clients.

I believe these emails SHOULD BE sent through MXroute servers, not directly by me. I want MXroute to handle (manage) all my emails.

Currently outbound mail is setup like this:
mydomain1,com - > someEmail@address,com

And it should be like this:
mydomain1,com -> echo,mxrouting,net -> someEmail@address,com

My current postfix/
mydestination = localhost, mydomain1,com, mydomain2,com
inet_interfaces = loopback

How do I setup Postfix to route my mail through MXroute?

(I had to replace . with , because I was getting an error that new users can only post 2 links, whatever that means )

Great question!

The most dynamic functionality here would be to configure your applications to handle SMTP individually, but if one overall config for the server is fine then postfix probably fits the bill just as well. Here’s what I’d do:

EDIT: Replace “” with the server we provision you on (in your “Important Account Information” email), and if you copy/paste the configs below the quotations need to be replaced, both the double and single quotations. Discourse is replacing them with stylized ones that will break configs.

echo “ username@yourdomain.tld:relevantpassword” > /etc/postfix/password

Replace “username@yourdomain.tld” with the email address you created on our system to handle this outbound mail, and “relevantpassword” with the password relative to that email account.


chown root:root /etc/postfix/password
chmod 0600 /etc/postfix/password
postmap hash:/etc/postfix/password

Now let’s make sure postfix configs don’t clash:

sed -i ‘s/relayhost/#relayhost/g’ /etc/postfix/
sed -i ‘s/smtp_sasl_auth_enable/#smtp_sasl_auth_enable/g’ /etc/postfix/
sed -i ‘s/smtp_sasl_security_options/#smtp_sasl_security_options/g’ /etc/postfix/
sed -i ‘s/smtpd_sasl_authenticated_header/#smtpd_sasl_authenticated_header/g’ /etc/postfix/
sed -i ‘s/smtp_tls_security_level/#smtp_tls_security_level/g’ /etc/postfix/


echo “relayhost =” >> /etc/postfix/
echo “smtp_sasl_auth_enable = yes” >> /etc/postfix/
echo “smtp_sasl_password_maps = hash:/etc/postfix/password” >> /etc/postfix/
echo “smtp_sasl_security_options = noanonymous” >> /etc/postfix/
echo “smtpd_sasl_authenticated_header = yes” >> /etc/postfix/
echo “smtp_tls_security_level = encrypt” >> /etc/postfix/


systemctl restart postfix

You should be set!

Thanks for your response Jarland, but i’m still having issues. Maybe there is something I am just not grasping here.

I’ve read lots of articles, and lots of comments here about how to setup and use MXroute But it seems to be, that the majority of people who use your service are using shared hosting or managed VPS. Because most of the tutorials I have found involve setting within cPanel or some other GUI. That is not my case, and I’m no expert in SMTP or Postfix.

In my case, I have a unmanaged VPS no GUI, I use CLI for everything. That’s not a problem and I rather have it that way. It’s just hard to figure it out, for the first time.

There are 2 paths I can go. One, the route you outlined above. Send everything from my VPS to MXroute. This involves individually setting up each and every email.

The other way to do it is to configure each and every domain to route to MXroute. This way might be easy for me. At least it would be easier to understand (at first).

I have followed your instructions above but am getting these error messages:

62206281508: to=<myemail@gmail,com>, relay=none, delay=13018, delays=13018/0.03/0/0.01, dsn=4.0.0, status=deferred (delivery temporarily suspended: SASL authentication failed; server echo,mxrouting,net[] said: 535 Incorrect authentication data)

So regardless, I have some type of authentication issue that needs to be resolved no matter what I do.

I can send email from my VPS server to my gmail account. They get flagged as spam (they should) but the point is they work. But, to get this done I had to REM out all smtp and smtpd statements you have to install above.

Let me try and put this as simple as possible. Lets get me working on a single domain first. Then when that works, I should be able to replicate what I did for other domains. Again, I am just sending transactional outgoing mail.

My VPS hostname (should be irrelevant) : 8374493,vpshost,com

I host on my VPS. And on MXroute i have defined multiple email info@domain,com, admin@domain,com, sales@domain,com

My Postfix settings within that I think are relevant:
myhostname = 8374493,vpshost,com
mydestination = $myhostname, 8374493,vpshost,com, localhost,localdomain, localhost, domain,com
inet_interfaces = loopback # send-only
inet_protocals = ipv4 # it could be all
mynetworks = [::ffff:]/104 [::1]/128

I had to REM all this out to get it working:
#relayhost = echo,mxrouting,net
#smtp_sasl_auth_enable = yes
#smtp_sasl_password_maps = hash:/etc/postfix/password
#smtp_sasl_security_options = noanonymous
#smtpd_sasl_authenticated_header = yes
#smtp_tls_security_level = encrypt

Now I think, you tell me, what I have to do next is re-enable relayhost = echo,mxrouting,net. Then fix the authentication failure problem I am having. How do I do that?

Or is there something I else I am missing?


So I either had a typo, I dont think so, or I forgot to do postmap. I’m pretty sure I never restarted Postfix previously. Anyways, no more authentication error. But, of course, I got a new problem.

to=<info@mydomain,com>, relay=local, delay=0.06, delays=0.03/0.02/0/0.02, dsn=5.1.1, status=bounced (unknown user: “info”)

I can login to webmail with info@mydomain,com no problem. So I’m confused with “unknown user info”

Now, if this is relevant, I created many users on your system with names like info@mydomain, support@mydomain, admin@mydomain. My password is horrible and easy to remember, uppercase, lowercase and a number. There is no way to get it wrong. But again, this is no long an authentication issue.

It’ now an unknown user issue. Any more ideas?

Hi Jarland, you were correct. It seems like my server thinks it the authority. I’ve changed the hostname to server,mydomain,com as you suggested. Still no luck. No more errors in the log files, it’s just that all emails are being sent to server,mydomain,com. If I read the local email I will see errors such as “unknown” user “username”.

Is there anyway you can contact me privately, or i can contact you? There is no way I’m going to reveal hosting information, configuration information, or email information here. Once this is resolved, I will be more than glad to post the results and the solution. But for now, I got to get this up and running. I got to be missing something simple (I hope).

What this most likely means is that the server you’re sending from thinks it’s the authority for, and is attempting to direct all email for local delivery rather than remote. Since you don’t have a user named “info” on that local system to receive mail at, it fails.

Most likely you should consider changing that server’s hostname from to something like so that the server doesn’t think it’s the authority for all things unless otherwise programmed specifically to be (like through web server virtual hosts / server blocks). It may also be listed in /etc/mailname besides just the hostname, as is common in some distros.

I might be able to help … I can be found in MXroute’s support chat at

I am not an expert at postfix, but can find my way around it.

Jarland’s recipe should work. I’m using similar setup. Create the password file, chown and chmod it and remember to run postmap.
Then of course need to read that password file and your mxroute server must be set to be relayhost. Then remember to reload postfix, maybe turn up verbosity for logging/debugging …
There’s quite a few articles out there on this, compare them to Jarland’s scripts, and you should get it going. I use this for all my VPSes and some standalone servers.

It seems that there may have been a typo when you did the first step. I would repeat it since the error is an authentication error.

Aye that seems to be the source of it. When you did this from my guide:

echo “ username@yourdomain.tld:relevantpassword” > /etc/postfix/password

I assume you set the variables in there to match what works on the Echo server (test in webmail to be sure). Be that the case, perhaps try a simpler password that consists only of letters and numbers (no symbols), then edit that password file to match. When finished, you’ll need to run this again:

postmap hash:/etc/postfix/password

Worth a try at least. Of valuable note is that I’ve not specifically tested the steps I gave you, but they’re very similar to configurations used internally.