CommandLineMail

Examples of sending email through a script on Linux.

Example 1

   1 #!/bin/sh
   2 #/home/user/sendemailscript.sh
   3 CURRDATE=`date -u "+%Y-%m-%dT%H:%m:%S.%Z"`
   4 FILE=/tmp/reportx$CURRDATE.txt
   5 SUBJECT="Report subject"
   6 BODY="Report body ...."
   7 MAILDESTINATION="dest1@example.org dest2@example.org"
   8 /usr/bin/python /home/user/script.py > $FILE
   9 echo $BODY | /bin/mail -a $FILE -s "$SUBJECT" -- $MAILDESTINATION
  10 #crontab -e  # run script at Six AM
  11 #0 6 * * * /home/user/sendemailscript.sh
  12 

CommandLineMail (last edited 2013-09-03 20:02:57 by 31)