Using the mail command to send mail from the command line from a script file




This is a script I wrote to send a warning email when a connection goes down.

HOSTS="bogus1.com \
       bogus2.com \
       bogus3.com"


SUBJECT="Your Internet connection is currently down"
TO="[email protected]"
CCTO="[email protected]"
TMPFILE=/tmp/mail-message

cat << EOF > $TMPFILE

Your Internet connection is down I could not ping

$HOSTS

I am attempting to automatically restart the connection.

If this fails (i.e. you can't get to http://www.hotmail.com) please contact the network administrator

EOF

mail -v -s "$SUBJECT" -c $CCTO $TO < $TMPFILE


[email protected]