Script to send email unix with sendmail

Plain text email:

cat << EOF | /usr/sbin/sendmail -t
to: myemail@mysite.com
from: "no reply" (Automated Processor)
subject: My subject

My email body.
EOF

Or HTML formatted email:

cat << EOF | /usr/sbin/sendmail -t
to: myemail@mysite.com
subject: My Subject
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="html_boundary"
--html_boundary
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/myscript.sh running from myuser cron)

EOF

Also useful: command line interface "mail -v myemail@myemail.com" 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?

    Mark

  • Leave a Reply

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