Dave's Brain

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.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.