Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rmckeel/94037100d9dc236c4044f6962a1bc3c6 to your computer and use it in GitHub Desktop.
Save rmckeel/94037100d9dc236c4044f6962a1bc3c6 to your computer and use it in GitHub Desktop.
Method for redirecting all email on a Linux WHM server for one domain to Mailgun for reliable delivery
# This allows you to route all email from a Linux WHM server using exim through the Mailgun service
# or other email service. This is very powerful because email from a server is typically untrusted
# and hard to get good email delivery.
# This is not tested on servers that host multiple domains, because Mailgun's service is specific
# to one domain. If you figure out multiple domains with Mailgun, write it in the comments or fork this!
# Log in to WHM, go to Exim Configuration Manager -> Advanced Editor tab then edit the following.
### NOTE!
# If setting hosts_require_auth and hosts_require_tls = smtp.mailgun.org,
# exim selectively authenticates. This is because Mailgun has a round-robin
# DNS service. exim thinks that it has already authenticated, but it winds up
# at a new IP address and doesn't authenticate. For more info:
# https://serverfault.com/questions/727198/exim-not-always-sending-auth-login-username-password
Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : [email protected] : password
Section: ROUTERSTART
mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::587 byname"
host_find_failed = defer
no_more
Section: TRANSPORTSTART
mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = *
hosts_require_tls = *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment