Linux Mail Command CLI

How to send?

mail -s “Enter the subject” user1@domain.com​


How to add message?

mail -s “The Subject” user1@domain.com < /root/testemail.txt

or

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” user1@domain.com

Multiple Receiver

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” user1@domain.com,user2@domain.com

CC and BCC

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” -c user1@domain.com,user2@domain.com​

Reply to

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” replyto= tom@gmail.com user1@domain.com

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” replyto= “Tomtom@gmail.com” user1@domain.com​


Attachments

echo “THIS IS A TEST EMAIL” | mail -s “Enter the subject” –r “Tom<tom@gmail.com>” –A /path/to/file user1@domain.com

Did you find this article useful?