cPanelResources

Tutorial How to use MailGun as a Smarthost

*** This guide is a task intended for system administrators. cPanel's Technical Analysts cannot provide assistance in configuring a server's Smarthost setup. ***

Overview
Many providers now block outbound connections on port 25, which means that a cPanel system would need to configure a Smarthost to allow for outbound emails to function. This resource will go through how to setup a Smarthost using a common 3rd party mail provider, MailGun.

Note: Click here to read the corresponding resource for setting up a smarthost with SendGrid.

It is important to note that configuring a Smarthost will cause all outbound emails to go through the configured provider. The scope of this resource does not cover only having certain domains go through a Smarthost. That would be something that must be configured by the system administrator of the server.

MailGun
The MailGun Smarthost setup instructions are similar to SendGrid Smarthost setup instructions. The main difference with MailGun is it uses "ROUTERSTART" instead of "PREROUTERS". MailGun has numerous plans, including a pay as you go plan. Their free tier offers 10,000 emails, 100 email validations, and a 5 day log retention.

1. First sign up for MailGun here if you have not already done so.

2. After signing up, log into WHM and navigate to WHM > Service Configuration > Exim Configuration Manager > Advanced Editor. On this page, search for "Section: AUTH". In the text box input the following:

Code:
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : EMAIL-USED-FOR-MAILGUN-SIGNUP:YOUR-MAILGUN-PASSWORD
Here's an image showing an example of how this should look:

mailgun-auth.png

3. Next go to the "Section: ROUTERSTART" section and input the following:

Code:
mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::587 byname"
host_find_failed = defer
no_more
Here's an image showing an example of how this should look:

mailgun-routerstart.png

4. Then, go to the "Section: TRANSPORTSTART" section. Input the following into the text box:

Code:
mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org
Here's an image showing an example of how this should look:

mailgun-transportstart.png

5. Go to the bottom of the page and click on "Save". The changes will get added to the Exim configuration and will automatically restart the Exim service.

6. Last, try sending a test email using one of the Webmail applications. If the email does not leave the server, then the /var/log/exim_mainlog file will need to be examined to determine the cause of the issue.

Questions/Feedback
Feel free to click on the Discussion tab to let us know if you have any questions or feedback about the information in this tutorial.
Author
cPanelResources
Views
361
First release
Last update