If all you really want from your Ubuntu Server is to be able to send you email if something goes wrong, or the occasional email to a trusted partner, friend, colleague, etc, then you want a simple solution. Although Postfix or sendmail, etc, will work in a satellite configuration, it’s still too heavy and over-the-top for this type of setup.
Enter sSMTP.
apt-get install ssmtp
Now open /etc/ssmtp/ssmtp.conf
in your favorite text editor and, to get it working on an example gmail account, set it up like so:
root=youremail@gmail.com mailhub=smtp.gmail.com:587 AuthUser=username AuthPass=password UseTLS=YES UseSTARTTLS=YES AuthMethod=LOGIN
Save the file, and you’re done.
Example for Amazon SES users. Be sure the sending domain is verified or mail will get rejected.:
root=youremail@gmail.com # from SES SMTP settings mailhub=email-smtp.us-east-1.amazonaws.com:587 AuthUser=username AuthPass=password UseTLS=YES AuthMethod=LOGIN
Important: You’re leaving your Gmail account password in a plaintext file. Make sure you’re using strong passwords. Even better, use Google 2-factor authentication so you can use an application-specific password for sSMTP.
UPDATE: Lastly, update the permissions
chown root:mail /etc/ssmtp/ssmtp.conf chmod 640 /etc/ssmtp/ssmtp.conf
Unprivileged users who have a need to send mail using sendmail must be a member of the mail group, or they will receive the following error:
mail: Cannot open mailhub:25
This was written for Ubuntu Server 12.04 64-bit.
Further reading:
- sSMTP- Debian Wiki – http://wiki.debian.org/sSMTP