November 8, 2015

Using Mailgun to send System Mail in Ubuntu 14.04 LTS

After running a mail server for a number of years I got fed up of managing spam and unreliable delivery for system mail. Expanding my recent of use mailgun for web applications I have now set it up to handle system mail. There was not a great deal on there on doing it with Ubuntu so here is a concise guide:

For simplicity I will assume you don't have an existing mailserver. If you do it may be easier to remove it using the purge option and start again.

smtp_sasl_auth_enable = yes relayhost = smtp_sasl_security_options = noanonymous smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd

Finished! A easy way of routing all your system mail through postfix. You will need to ensure you have added your custom domain into mailgun. For example if your server is called: then add this as a custom domain to mailgun. If some mail is sent as from the server don't worry this configuration will still work and is simple as it does not interfere with the mail provider serving your domain. Even DKIM and SPF work without any changes.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus