Trending News


How to Use a Linux Command to Send Email from Gmail or SMTP

How to Use a Linux Command to Send Email from Gmail or SMTP 

Linux Command

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 ""   \
    -u "Email Subject 1"     \
    -t "" \
    -s ""  \
    -o tls=yes \
    -xu "" \
    -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 ""  \
    -u "Email Subject 2"  \
    -t ""  \
    -cc ""  \
    -bcc ""  \
    -s ""  \
    -o tls=yes  \
    -xu ""  \
    -xp "Email Password"
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on vk
Share on tumblr
Share on skype
Share on stumbleupon
Share on whatsapp

Related posts

Leave a Reply

Required fields are marked *