#!/bin/sh # Bourne shell script to send a message file about a given subject to # a person with a given email address # Bill Bynum # August 1998 sysbin=/usr/localbin:/usr/local/gnu/bin:/bin:/usr/bin:/usr/lib otherbin=/home/f85/bynum/bin:$HOME/bin PATH=$sysbin:$otherbin:. PAUSE=2 usage(){ echo "Usage: $pgmname [-d] \"person name\" mailaddr msg_fname \"subject\"" echo " 'person_name' is the person's name" echo " 'mailaddr' is the person's e-mail address" echo " 'msg_fname' is the name of the message file" echo " 'subject' is the subject of the message file" echo " >>>> ALL FOUR PARAMETERS ARE REQUIRED <<<<" echo " -d debug (show message as it would be sent, but don't send it)" } pgmname=$0 case $# in 0|1|2|3) usage exit;; esac while true do case $1 in -d) debug=T shift;; -*) echo "Unknown option \"$1\"" usage exit;; *) break;; esac done case $# in 0|1|2|3) usage exit;; esac if (test ! -f $3) then echo "Message file \"$3\" does not exist!" exit fi echo Sending a message to $1 echo "To: $2" > tmsg echo "Subject: $4" >> tmsg echo "" >> tmsg date >> tmsg echo "" >> tmsg echo "Dear $1," >> tmsg echo "" >> tmsg cat $3 >> tmsg echo "" echo Message to be sent: echo "" cat ./tmsg if (test "$debug" = "T") then echo "No message sent (just debugging)" else echo "Pause $PAUSE seconds for Postfix" sleep $PAUSE sendmail $2 < ./tmsg fi rm -f ./tmsg # # $Id: sendmsg,v 1.5 2005/09/19 14:36:40 bynum Exp $ #