SMTP relay via Mandrill Service

SMTP relay via Mandrill Service

Submitted by Jitesh Doshi on Fri, 01/10/2014 - 12:26

If you have ever tried to send emails from your dedicated server in the cloud to either a mailing list or to individual users of your site, you would know that it is not as simple as it sounds. Depending upon the reputation of the IP address asigned to your server, many large email providers might block your emails - even though you have a perfectly legitimate reason to send this email, and your company has never spammed anyone. The solution we implemented was subscribing to the excellent Mandrill transactional email server from and sending all our emails via them. The problem then is how to makes sure all your emails as routed (relayed) through them? For your Drupal emails, you can use the Mandrill module, but that covers only Drupal (and has other issues). So what we really did was route emails to Mandrill at SMTP MTA (Mail Transport Agent) configuration level itself. The rest of the article describes how.We use Debian Linux, which uses exim4 as the default MTA. To reconfigure it, just run sudo dpkg-reconfigure exim4-config, and follow the screens. You can take the defaults, except in the following three cases:

  • Type of mail configuration - mail sent by smarthost; no local mail
  • System mail name - (or whatever your primary domain name is)
  • IP address or host name of the outgoing smarthost - (this is most important)

Exim4 - Type of mail configuration

Exim4 - System mail name

Exim4 - Outgoing smarthost

Exit the configuration program and then there is one more VERY IMPORTANT thing. You must edit /etc/exim4/passwd.client file (as root or using sudo) and add the following line to it:


You can find your Mandrill API from after logging in.

That's it. Now all emails going out of your server will be relayed through Mandrill, and thus (hopefully) not rejected by your recepient's email providers. Happy emailing!

Jitesh Doshi

Profile picture for user Jitesh Doshi
Managing Partner & CTO
  • A seasoned technology entrepreneur and enthusiast
  • A regular speaker at industry conferences and universities
  • Host and organizer of technology user groups
  • Active in management of non-profit organizations serving the local community
  • Leader and contributor for multiple open-source projects
  • Expert in cloud, application integration, web and mobile technologies
  • Author of open-source projects, including on - Popular Tags and PRLP.
  • Developed several highly successful software platforms and frameworks for clients