Use Mandrill with Exim on cPanel/WHM to Solve SPAM email Issue

If you are using phpmail or sendmail function in your website, you may notice that, some of the email may end up in SPAM folder of the intended recipients. The situation become worsen if the intended recipients are using hotmail/livemail/outlook, which has stricter filtering. The recipient may not receive the email at all. Not even in Junk folder.

This is a big issue if you are running an e-commerce and even bigger issue for newsletter/mailing list website like Interspire Email Marketer.

To solve this issue, we can use transactional email or bulk email service such as Mandrill with Exim on cPanel/WHM server.

To integrate Mandrill with Exim on cPanel/WHM, we have to add proper settings as below.


1. Login to WHM with a root access & browse to

WHM → Service Configuration → Exim Configuration Manager → Basic Editor


2. In “Mail → Smarthost support”, add the following



3. Browse to

WHM → Service Configuration → Exim Configuration Manager → Advanced Editor


4. Search for – “Section: AUTH” & add the following code. Change youremail@yourdomain : api-key with your email & Mandrill API Key

driver = plaintext
public_name = LOGIN
hide client_send = : youremail@yourdomain : api-key


5. Search for – “Section: PREROUTERS” & add the following code.

driver = manualroute
domains = ! +local_domains
ignore_target_hosts =
transport = auth_relay
route_list = *


6. Search for – “Section: TRANSPORTSTART” & add the following code.

driver = smtp
port = 587
hosts_require_auth = $host_address
hosts_require_tls = $host_address


7. Save the new configuration.

8. Send a test email & you should see the email header should have something with *

15 comments… add one
  • This is feasible if I have many domains in WHM for my clients? As affected your email accounts?

  • My question is the same as gnxdevelop.

    I have several accounts in my WHM– Will this process still work?

  • gnxdevelop & Mitch,

    Yes, this will work for all account in WHM.

  • I just tried this and my emails arent showing in mandrill dashboard or my inbox? If im thinking correct we just need to send mail just like with the php mail function right?

    • Make sure you set the correct e-mail address & API key step 4. After you do this, all mail send through sendmail or PHP Mail function will go through Mandrill.

  • Did everything you said, but it does not work for me .
    When sending a mail it still goes trough phpmail 🙁

  • I was wondering if it works on all accounts on WHM, do we have to verified domains in Mandrill? Can choose which domain to use Mandrill or not to use?

    • Yes, it will works on all account. Preferably, to verify the domain that you want to use Mandrill.

  • Hello,
    I want know if is possible to configure exim (on postfix is possible) use of mandrill only for some domain and other local smtp
    domain1,2,3 and 4 are all domains configured as website on my server, but I would that when with php use mail() function, exim sends mail from mandrill or localsmtp, based on my rules
    Example (I would configure FROM domain, not TO):
    domain1.tld -> use mandrill
    domain2.tld -> use local smtp
    domain3.tld -> use local smtp
    domain4.tld -> use mandrill

    thanks in advance

  • Hi there,

    Your post about Mandrill seems interesting. I never heard about this tool, so I would like to ask you something. I have a hosting webpage which offers you to pay for a hosting (web + domain) and emails. We use cPanel and mail is sent through exim, but recently I’ve been notified by OVH, which is our server provider, that detected an spam attack from our server, probably because one of our clients has a PC infected with a virus and started to send many many mails…

    Can I use this tool to redirect SMTP and use Mandrill servers for outgoing mail to prevent OVH to block our port 25?

    If this happens none of our domains could send mails. Furthermore, OVH could block our server if they detect that server it’s used for spam and this can happen many times each day when we reach certain amount of clients.

    Thanks in advance for your time.


  • The settings work great and all email is passed through mandrill.
    However, even email used in Outlook or any mail client is diverted through mandrill, not just website php mail.
    Is there a way to leave outlook emails going through normal mailserver and only sendmail from website code being redirected through mandrill?

  • I have tested this and it works fine.
    The only issue that emails that are to be auto-forwarded by cPanel’s account auto-forwarder are being rejected by Mandrill, as it seem to “think” the server is trying to send emails on behalf of external domains.
    Is there any way to fix this or simply skip the smarthost altogether (and use standard exim) for the auto-forwarder rules?

    Thank you

    • I am in the same boat as you re: forwards. Let me know if there is anything you find out.

      • Same here,

  • Hello,

    I exactly did the settings, Yet
    Error: authentication failed: UGFzc3dvcmQ6 appears.

    The Session reads as under:
    delivering 1lvIGJ-0002XJ-DK
    Connecting to []:587 … connected
    SMTP<> EHLO mailhawk
    SMTP<> EHLO mailhawk
    SMTP<> ****************************************
    SMTP<> ********************************************


Leave a Comment