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:
And you are done! It goes without saying how important keeping an eye on system emails is.