Use MailGun as a Smarthost with WHM/ cPanel server

You can use MailGun as a smarthost to send emails from your cPanel server. To allow MailGun to send outgoing emails from your cPanel/ WHM server You would require to setup exim server on your cPanel/WHM server.

What is MailGun
MailGun offer several plans for outgoing emails. Their free plan offers 5,000 emails for first three month, and 0.80$ for 1000 emails afterward , and 5-day log-retention. You can sign up with MailGun following this URL MainGun Sign up:

Configure MailGun on your WHM/ cPanel server:

1. Log in to your WHM as the root user, navigate to Home » Service Configuration » Exim Configuration Manager » Advanced Editor . search for “Section: AUTH” and input the following string in text box:

mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : Default-SMTP-Login:Default-Password

Note: You can find Default-SMTP-Login and Default-Password in your MailGun account under Domain Settings section.

3. In Exim Advanced Editor, search for the the “Section: ROUTERSTART” box, and input the following in the text box:

mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = “* smtp.mailgun.org::587 byname”
host_find_failed = defer
no_more

4. Add the following into the “Section: TRANSPORTSTART” text box:

mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org

5. Scroll down to bottom of the page, and click on “Save” button to apply changes.
This will save the changes you applied and it will automatically restarts the Exim service.

6. Now try sending a test email, preferably from one of the Webmail applications or from any cPanel account web mail interface to verify.

If you see emails are stuck in mail queue of server, you need to check the /var/log/exim_mainlog file to find the reason .

Leave a comment

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