Send system emails using gmail as smtp server

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

I wrote before about sending system emails using sendmail as smarthost.
Today I describe how to do that using gmail smtp servers.
The software that will allow us to do that is called “ssmtp” and it’s a “send-only sendmail emulator for machines which normally pick their mail up from a centralized mailhub (via pop, imap, nfs mounts or other means)”.

You can install it on Debian/Ubuntu with:

apt-get install ssmtp

The configuration files are under “/etc/ssmtp”.

The first that we need to modify is “ssmtp.conf” and it has to look something like this:

[email protected]
mailhub=smtp.gmail.com:587
hostname=myHostname.com
UseSTARTTLS=YES
AuthUser=gmailUsername
AuthPass=gmailPassword
FromLineOverride=YES

The second file is “revaliases” and you need to add an entry for each user you want to target.
For example for the root user you do:

root:[email protected]:smtp.gmail.com:587

And you are done! It goes without saying how important keeping an eye on system emails is.

One thought on “Send system emails using gmail as smtp server”

Leave a Reply

Your email address will not be published. Required fields are marked *