#!/bin/csh -f
# "mymail"
# Script to send mail file to large list of addresses contained in the
# file mymail.list  A logfile listing the recipient, the name of the
# file sent, and the date is kept in a file named mymail-mmddyy.log.
#
# modified 12/14/92 -- DHB added sleep command
set com = $0
set todate=`date +%m%d%y`
if ($#argv != 3) then
    echo "Usage: $com:t"  '"subject for mailing"'  file-to-mail  mailing-list-file
    exit 1
endif
set logfile=$argv[3]-$todate.log
touch $logfile
#
if (! -e $argv[3].list) then
    echo "Couldn't find your list of mail addresses."
    echo Please check for the file $argv[3].list and restart.
    exit 1
endif
#
if (! -e $argv[2]) then
    echo "Couldn't find your mailing-file,  $argv[2]."
    echo "Please check for the file $argv[2] and restart."
    exit 1
endif
#
foreach name (`cat $argv[3].list`)
    cat $argv[2] | mailx -s "$argv[1]" $name
    set nowtime=`date +%m/%d/%y:%H:%M`
    echo "$name sent $argv[2] on $nowtime" >> $logfile
    echo "$name sent $argv[2] on $nowtime" 
    sleep 1
end
exit
