twitter

How To's Tutorials

Send E-mails from linux command line or terminal using Mutt ,Mail & Telnet

 

Mutt :  Mutt is a small but  powerful text-based e-mail client for Unix like operating systems. With mutt command one can send and read emails. Mutt supports both maildir & mbox mail formats. Mutt is compatible with POP & IMAP protocols.

 

Syntax :

 

# mutt -s “Subject of the Mail” recipient-address@domain.com <  /dev/null

 

 

Example:1 Send a test mail where the mail body is blank

 

# mutt -s “Test Mail” nextstep4it@gmail.com < /dev/null

 

Above Command will send a mail with subject “ Test Mail” to nextstep4it@gmail.com

 

Example :2 Send Mail with attachments

 

Syntax :

 

 # mutt   -s “ Subject of the Mail” -a  /tmp/<file-to-be-attached> recipient-address@ domain .com < /tmp/<mail body contents file>

 

# mutt  -s “test mail plz ignore” -a /tmp/backup.tgz  nextstep4it@gmail.com </tmp/body.txt

 

NOTE: When we send mail from the console , mail sender name will be root(in case if we are logged in with root user) if we want to change the sender name and email , then Create a file in user's home directory.

 

cat .muttrc

set from = "noreply@nsitmail.com"

set realname = "MAIL ADMIN"

 

Mail : Mail is an  e-mail client , which is used ti send and receive mails.

 

Syntax :

 

# mail  -s <subject>   -c <cc-addr>   -b <bcc-addr>       to-addr...  </mailbody.txt

 

Example:1

 

# mail -s "test mail plgz ignore" nextstep4it@gmail.com </tmp/body.txt

 

Above Command will  send mail with  subject “test mail plz ignore” and  body of mail will be the contents of /tmp/body.txt file.

 

Telnet :  The telnet command is used to communicate with another host using the TELNET protocol.  Telnet can be used to send mails , as show below :

 

 

Where :

 

mail from :  specify  the e-mail id from where the mail will be send.
rcpt to : specify the recipient email-id
data : it is the command after which we can specify the subject of the mail 
Subject: subject of the mail
quit : is the command to exit

pallavi on, 2014-01-30 06:15:42
It is really very useful tutorial
Manjunath on, 2013-11-19 12:16:42
I need send the 2 attachments at a time using mutt command ? Is it possiable ? If i know pls send me the script for below mail pmanju2010@gmail.com . Thanks advance
Post Your Comments
Name:
Email:
Comment:
Security Code  *
Enter Security Code  *
Can't read the image? click here to refresh