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-get install ssmtp
$ vim /etc/ssmtp/ssmtp.conf
For sending emails using your Gmail Account
hostname=YOUR-EmailServer root="Your Gmail ID" AuthUser="Your Gmail ID" AuthPass="Your Gmail Account Password" FromLineOverride=YES mailhub=smtp.gmail.com:587 UseSTARTTLS=YES
Now, we will create a simple text file “message.txt”, which contains the actual message to be sent, the format for this text file should be similar to as below,
From: "Your Gmail Id" Subject: "The subject you want" The Text Message you want to be sent
Now, we need to use the above message.txt and below command to send an email from the ubuntu command line as,
$ /usr/sbin/ssmtp "Email Id of receiver" < ./message.txt
Now, your receiving email id which you have mentioned in above command, should have received an email with contents from message.txt
For sending emails using your Amazon AWS / SES account, you need to use appropriate AuthUser and AuthPass and need to change mailhub to "mailhub=email-smtp.us-west-2.amazonaws.com:465"