Configure nullmailer to use SMTP authentication

nullmailer is a minimalistic and easy to configure MTA (mail transport agent). It is described on the homepage as follows:

Nullmailer is a mail transport agent designed to only relay all its messages through a fixed set of “upstream” hosts. It is also designed to be secure.

nullmailer is a good choice for systems that do not receive, but send mails like for example web servers.

To setup nullmailer to relay the mails to a smtp server that needs smtp authentication, just add the login credentials to the configuration file (/etc/nullmailer/remotes on Ubuntu systems)

[YOUR-SMPT-SERVER.COM] smtp --auth-login --user=[USER] --pass=[PASSWORD]

and (for security reasons) set the permissions as follows:

# sudo chown mail /etc/nullmailer/remotes
# sudo chmod go-rwx /etc/nullmailer/remotes

Finally, restart the nullmailer service

# sudo /etc/init.d/nullmailer restart

To test the configuration, just use the mail command to send an e-mail:

# echo "This is a test e-mail..." | mail -s "Test e-mail" [YOUR-E-MAIL-ADDRESS]