Simple outbound email configuration for Ubuntu Server 12.04 using sSMTP

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:

Save the file, and you’re done.

Example for Amazon SES users. Be sure the sending domain is verified or mail will get rejected.:
# from SES SMTP settings

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:


, , , , ,