SSMTP is a program which delivers email from a local computer to a configured mailhost (mailhub). It is not a mail server (like feature-rich mail server sendmail) and does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address.
$ sudo apt install ssmtp
Configuration can be found in nano /etc/ssmtp/ssmtp.conf
. Add the following lines for Gmail.
[email protected]
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=server hostname
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES
Now add reverse aliases in /etc/ssmtp/revaliases
.
root:[email protected]:smtp.gmail.com:587
Now you're all set!
$ ssmtp [email protected]
sSMTP will then wait for you to type your message, which needs to be formatted like this:
To: [email protected]
From: [email protected]
Subject: test email
Hello World!
Send your email with CTRL+D.