Sending mail from command line or shell program

Sending mail from command line or shell program. It is simple but tend to forget time to time. So here is a quick note, an excerpt from “How to send email from the Linux command line” article.

mail -s “Hello world” email@address.com
ENTER then type message body then CTRL+D.

Otherwise, echo “This will go into the body of the mail.” | mail -s “Hello world” email@address.com

Or parse from file, mail -s “Hello world” email@address.com < /tmp/message.log

Use mutt for attaching file, echo “Sending an attachment.” | mutt -a backup.zip -s “attachment” email@address.com

Bashing…