Aug 26, 2011
Jason

Simple bash mail script

If you want to automate something on any Unix based servers and want to send you email in the bash script, here is the simple one.

#!/bin/bash
FROM="from_address@example.com"
TO=”to_address@example.com”
SUBJECT="Test Subject”
EMAILMESSAGE=”Test Message”

/bin/mail -s "$SUBJECT" "$TO" < $EMAILMESSAGE — -f $FROM

I hope this script will be helpful for you and feel free to leave a comment if you need any help.

Leave a comment