How to Send Email from Linux Command Line using SSMTP ( Ubuntu, Gmail, Amazon AWS )

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

root="Your Gmail ID"
AuthUser="Your Gmail ID"
AuthPass="Your Gmail Account Password"

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 ""

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question