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

*: smtp.mandrillapp.com

 

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

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

 

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

smart_route:
driver = manualroute
domains = ! +local_domains
ignore_target_hosts = 127.0.0.0/8
transport = auth_relay
route_list = * smtp.mandrillapp.com
no_more

 

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

auth_relay:
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 *mandrill.com



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

    Reply
  • My question is the same as gnxdevelop.

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

    Reply
  • gnxdevelop & Mitch,

    Yes, this will work for all account in WHM.

    Reply
  • 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?

    Reply
    • 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.

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

    Reply
  • 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?

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

      Reply
  • 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

    Reply
  • 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.

    Regards,
    Diego.

    Reply
  • 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?
    Thanks

    Reply
  • 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

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

      Reply
      • Same here,

        Reply

Leave a Comment