Use sendmail. Here is an example:
Code:
/usr/sbin/sendmail "user@some.somain" << EOF
From: Me <user@another.domain>
To: Mario Rossi <user@some.domain>
Subject: testmail - $status
$(date "+%A %e %b %Y %T") - status is - $status
$(cat $logfile)
$([ -f $errfile ] && cat $errfile)
EOF
You can also send an e-mail in HTML format. I use this to colorize some flags in a log report:
Code:
(
echo "From: Me <user@domain>"
echo "To: Mario Rossi <user@some.domain>"
echo "Cc: Luigi Bianchi <user@domain>"
echo "Subject: Report - $status"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
echo
echo "<pre>$(date +"%A %_d %b %Y %H:%M:%S") - status is $status_c</pre>"
echo
cat $HOME/log.html
echo
) | /usr/sbin/sendmail "user@domain"
As you can see you can embed shell variables and command substitution in the mail body or in the Subject field.