Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Tutorial How to use MailGun as a Smarthost

Enabling MailGun as an Exim Smarthost with cPanel & WHM

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

    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.

    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:

    driver = plaintext
    public_name = LOGIN
    Here's an image showing an example of how this should look:


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

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


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

    driver = smtp
    hosts =
    hosts_require_auth =
    hosts_require_tls =
    Here's an image showing an example of how this should look:


    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.

    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.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice