Simple Mail setup in Linux with SSMTP

linux-email
Is it possible to set up system mail on a linux box to be sent via a different smtp server – maybe even with authentication? If so, how do I do this?

sSMTP very simple to use.

apt-get install ssmtp

Then edit the configuration file in /etc/ssmtp/ssmtp.conf

A sample configuration to use your gmail for sending e-mails:

# root is the person who gets all mail for userids < 1000
root=your@email.com

# Here is the gmail configuration (or change it to your private smtp server)
mailhub=smtp.gmail.com:587
AuthUser=your@gmail.com
AuthPass=yourGmailPass
UseTLS=YES
UseSTARTTLS=YES

 

Note: Make sure the “mail” command is present in your system. mailutils package should provide this one in Debian based systems.

Update: There are people (and bug reports for different Linux distributions) reporting that sSMTP will not accept passwords with a ‘space’ or ‘#’ character. If sSMTP is not working for you, this may be the case.