Easy system email relay with Nullmailer and Mandrill
Installing and configuring Postfix or Exim often feels like rocket science to get everything set up without any security holes. But those days are over; meet the awesome Nullmailer + Mandrill combo!
Nullmailer provides a sendmail compatible email interface that can forward emails to an external SMTP server. This allows you to leverage a third party service like Mandrill to handle all your mail traffic with a pretty admin interface to monitor everything.
Start by installing the nullmailer package:
apt-get install nullmailer
When that's done, there are only a few files that need to be modified. The first one is
/etc/nullmailer/remotes where you specify the remote SMTP server. You can find your SMTP credentials in the Mandrill settings section.
smtp.mandrillapp.com smtp --port=587 --starttls --user=<email> --pass=<password>
Then modify and execute these commands to fit your configured Mandrill domain:
sudo echo "example.com" > /etc/mailname sudo echo "example.com" > /etc/nullmailer/defaultdomain sudo echo "server1.example.com" > /etc/nullmailer/me sudo echo "[email protected]" > /etc/nullmailer/adminaddr
Now reload Nullmailer and you are ready to go!
sudo service nullmailer reload
To test if everything is working correctly, try sending an email to yourself:
echo "Hello world from $HOSTNAME" | sendmail [email protected]