Script to send email unix with sendmail

Plain text email:

cat << EOF | /usr/sbin/sendmail -t
from: "no reply" (Automated Processor)
subject: My subject

My email body.

Or HTML formatted email:

cat << EOF | /usr/sbin/sendmail -t
subject: My Subject
MIME-Version: 1.0
Content-Type: multipart/alternative;
Content-Type: text/html

1) Errors (if any). Errors here imply a database backup failure.
`grep -i error logfile.log` 

2) Elapsed times. (with trailing whitespace and Ctrl-M removed).

`sed -e 's/[ \t]*$//' -e 's/^M//g' < logfile.log` 

(end of file - This email produced from myserver:/mypath/ running from myuser cron)


Also useful: command line interface "mail -v" followed by a "." to send the email.

April 9, 2010

  • Hi Andrew,

    Any ideas on best way to inform an external app that a weekly table update has completed so that the apps reports can start?


  • Leave a Reply

    Your email address will not be published. Required fields are marked *