Question: how to send email?Linux includes a large number of commands commands that allow you to send email from the command line. Here use simple Linux Command Into Send Emails To The Inbox Every Time.
We all know the importance of emails these days for details transfer. There are many free emails service providers which we accustomed for use like ProtonMail, Gmail, Outlook, Yahoo Mail, RediffMail, Zoho, mailx etc, which provides a web interface for sending and receiving emails. But this is not enough, sometimes I as well necessary to send emails from system command line. Big tutorial will allocate you multiple methods to send emails from the Linux command line. This is helpful for successfully sending email between our main shell scripts, any type of the cronjobs or crontab mailx etc.
Send Email from the Linux Command Line Examples
step by step Sending email from the Linux echo command line is necessary when you need to make emails from a shell script.You can use any one of the below to successfully send email from the Linux Terminal or CMD command line.
The flow chart below can explain more about that.
|Way + Command List||Syntax|
$ssmtp [email protected] Subject: Experiment SSMTP Email Email send test using SSMTP via SMTP server. ^d
|implement ‘telnet’||Below More Details…..|
There are different more Important methods to send emails from the echo command line but here I am sharing one or two options accustomed by most users. You can use choose a public optional option specified below to send email from Linux command line.
1. implement ‘sendmail’ Command
“Sendmail” is a most popular SMTP server accustomed in most of Linux/Unix distribution. Sendmail allows sending email from echo command line. Use below directive to send email using ‘sendmail‘ command.
Created a file with email content:
$cat /tmp/email.txt Subject: Pakainfo Terminal Email Send Email send Good Bolly4u 2020 Content is King line 1 Email Great Big Data Content mp3goo line 2
Mail Subject: line will be accustomed as subject for email.
After that you can send email using the below simple great command.
$ sendmail [email protected] < /tmp/email.txt
2. implement ‘mail’ Command
Here, You can step by step using a mail CMD echo command is few fresh command to send emails from Linux terminal. Use one or two of below very easy and genuine examples to send an email.
$ mail -s "Experiment Pakainfo Mail Subject" [email protected] < /dev/null
-s is accustomed for defining subject for email.
as well as, you can send an attachment successfully with this best command. Use -a stands for a mailx with -A stands for a for mailutils.
$ mail -a /opt/backup.sql -s "Backup File" [email protected] < /dev/null
I use a -a is accustomed for file or Images or any types of the attachments. Use -A for debian based Live systems, which uses simple extra added the mailutils package.
as well, I can included special char like as comma separated emails to proper send the email to multiple users as a recipients together successfully.
$ mail -s "Experiment Email" [email protected],[email protected] < /dev/null
3. implement ‘mutt’ command
Mutt is basically accustomed for reading emails from Terminal to Linux terminal from local customer mailboxes, as well as helpful to read emails from POP/IMAP servers. Mutt command is little similar to mail echo command. Use one or two of below some best helpful genuine examples to proper send an email successfully.
$ mutt -s "Experiment Email" [email protected] < /dev/null
Send an email including an attachment
$ mutt -s "Experiment Email" -a /opt/backup.sql [email protected] < /dev/null
4. implement ‘SSMTP’ Command
sSMTP allows customers to send emails for newbie from SMTP server from Terminal to Linux command line. For example to send an email to customer [email protected] use below command. And then you can type your main Great subject of the email as below with a Focus keyword put in your very attractive Subject Line. After that type your some message to be sent to the customer, After last step to you can finishing your message press simple CTRL+d (^d) to send the email.
$ ssmtp [email protected] Subject: Experiment Pakainfo SSMTP Email Email send test using SSMTP via SMTP server. ^d
5. implement ‘telnet’ Command
As per According to me, all the system for Main Root Level administrators use telnet any type of the command to simply you can test purpose remote port check the data connectivity easyly test or signin means Login system to the server based remotely. we know Most of the case beginner devloper in Linux Terminal to doesn’t all about know that I can send best way to email using telnet as well, which is the more better level to any type of the troubleshoot email sending problems. Below is very easy and tiny an example of step by step email sending.
Red marked text is the customer input and remaining is the responses of that commands.
$ telnet localhost smtp Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 infinityknow.com ESMTP Sendmail 8.13.8/8.13.8; FRI, 29 Apr 2019 08:09:59 -0400 WELCOME TO yahoo.com 250 pakainfo.net Hello pakainfo.net [127.0.0.1], pleased free to Search Results Web results Bolly4u 2019 mail from: [email protected] 250 2.1.0 [email protected] Sender ok rcpt to: [email protected] 250 2.1.5 [email protected] Recipient ok data 354 press the Enter mail, end with "." on a line by coding or put the itself Gretting name, It is a simple testing for the v2 Mail Send - Send Email Using HTTP Thanks a lot . 250 2.0.0 r9M95xgc014513 some Message accepted for mail delivery quit 221 2.0.0 infinityknow.com closing connection Connection closed by foreign host.
Sending email to multiple recipients
If you want to simple “recipients” Based send email from the Terminal using Linux command line to a big group of recipients, you can always use a loop to make the job easier as in this example using mutt.
$ for notify in `cat notifys` do mutt -s "about the Minutes from May offical work for Pakainfo" $notify < May_minutes done
There are quite a Most Imp 5 Ways to Send Email From Linux Terminal to Command Line. Some tools allocate quite a 5 simple and easy options.
Thank you for using this Post. I shall include more some methods soon with this all the helpful commands list. I as well request you to help me with more Advanced Level More commands which you free to know as well as not listed above please commenting.
Here are some more FAQ related to this Article: