Published January 13, 2018 by

mail: command not found in Linux & Working with 'mail' command

In Linux mail command is used for sending mail from your Linux server/machine.

Install 'mail' command

For CentOS/Redhat
 yum install mailx  
For Ubuntu/Debian
 sudo apt-get install mailutils
For Fedora
 dnf install mailx
Sending Mail

1. Send Full Mail using the following command:
 mail -s "Hello World" it.subhashpatel@gmail.com
OR you can also send mail to multiple recipients:
 mail -s "Hello World" it.subhashpatel@gmail.com,it.subhashpatel@yahoo.com
it asks for cc: and mail body
 # mail -s "Hello World" it.subhashpatel@gmail.com  
 Cc: it.subhashpatel@yahoo.com  
 Hi Subhash  
 How are you  
 This is Test Mail  
 <Ctrl+D>  
Press Ctrl+D for send mail

2. Mail in a Single Line
 mail -s "subject" it.subhashpatel@gmail.com <<< 'mail body'