Browse - Programming Tips - How can I send mail from a bash script?

Date: 2012mar22
OS: Linux
Language: bash

Q.  How can I send mail from a bash script?

A.

echo hello | mail -s 'Subject of this mail' <receiver-address>
Where <receiver-address> is where you want the mail to go. It can be just the userid on this box or a full mail address such as user@host.com Also you can use $USER to send mail to the user that is running the script.