#!/bin/sh
# Adapted by Jacob Gore from notesmail, which was
# adapted (not sure by whom) from Rnmail, which was
# written by Larry Wall <lwall@sdcrdcf.???>
# 
# syntax: $0 -h headerfile 

# Customizable stuff
#
AWK=/usr/local/bin/nawk
AWKFILE=/local/byname/notes/lib/notessend.awk

# The rest should need no customization
#
trap 'rm -f $tempfile; exit' 0 1 2 3 15
logfile=/tmp/nfm_error
tempfile=/tmp/nfm_msg$$; export tempfile
case $# in
2)
    case $1 in
        -h)
	    headerfile="$2"
	;;
        *) echo \
	   "Aaahhhh! Notessend called with strange parameters! Cannot mail" \
	   >> $logfile
	   exit 1
	;;
    esac
;;
*)
    echo "Aaahhhh! Notessend called with strange parameters! Cannot mail" \
	>> $logfile
    exit 1
;;
esac

command=`$AWK -f $AWKFILE < $headerfile`
eval $command
rm -f $tempfile
exit 0
