How to Use a Linux Command to Send Email from Gmail or SMTP
In a previous tutorial, we covered SSMTP, which allows you to send email using the Linux command line using an SMTP server. Using the send email command-line utility, this tutorial makes the operation even simpler. SendEmail is a lightweight command-line SMTP email client that allows you to send emails over an SMTP server. We also covered how to install the send email kit as well as a few explanations of how to send email using a remote SMTP server like Gmail in this article.
Table of Contents
Install the SendEmail Package
The SendEmail SMTP client is available in the Ubuntu default repositories; use the commands below to install it.
sudo apt-get update sudo apt-get install sendemail
Sending Email Through SMTP
Example 1: In this example, the email body text is passed as an argument to the command (-o message-file=/tmp/mailbody.txt).
sendemail -l email.log \ -f "firstname.lastname@example.org" \ -u "Email Subject 1" \ -t "email@example.com" \ -s "smtp.gmail.com:587" \ -o tls=yes \ -xu "firstname.lastname@example.org" \ -xp "Email Password" \ -o message-file="/tmp/mailbody.txt"
Example 2: In this example, the email body text is piped in from the output of another command. You may also include a cc and bcc email address.
cat mailbody.txt | sendemail -l email.log \ -f "email@example.com" \ -u "Email Subject 2" \ -t "firstname.lastname@example.org" \ -cc "email@example.com" \ -bcc "firstname.lastname@example.org" \ -s "smtp.gmail.com:587" \ -o tls=yes \ -xu "email@example.com" \ -xp "Email Password"
How to use Registry Editor to navigate to any Registry key with a single click
You might get tired of manually navigating to various registry keys if you find yourself fiddling with Registry Editor and…