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 https://mandrillapp.com/ 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 - yourdomain.com (or whatever your primary domain name is)
- IP address or host name of the outgoing smarthost - smtp.mandrillapp.com::587 (this is most important)
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:
*.mandrillapp.com:your-mandrill-username@yourdomain.com:your-mandrill-api-key
You can find your Mandrill API from https://mandrillapp.com/settings/index 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!