Example Send Mail Script

This (status monitoring) script builds the message then uses sendmail to send it:

#!/bin/sh

OLD_STAT=`cat /tmp/cciss.c0d0.ok`
NEW_STAT=`/usr/local/bin/cciss_vol_status /dev/cciss/c0d0`
SUBJ="XENSERVER 01"

DATE=`date +%H`

mail ()
{
stat=$1
shift
( echo "From: yourmail@domain.org"
echo "Reply-to: yourmail@domain.org"
echo "To: servicestatus@domain.org"
echo "Subject: $SUBJ"
echo
echo "RAID status:"
echo "$stat"
echo "" ) | sendmail -F "RAID STATUS" -f yourmail@domain.org $@
}

$DATE -eq 8 -o "${OLD_STAT}x" != "${NEW_STAT}x" && \
mail "$NEW_STAT" yourmail@domain.org