#!/bin/sh

#
# Setup who sent and who was supposed to receive all this
#
xamimeLTid=$1
sender=$2
admin=$3
homedir=$4
reportname=$5
sendmail_bin=$6
sendmail_flags=$7
rfcdate=$8
receivers=$9

server_name=`echo $sender| cut -d@ -f2`

#
# Setup the output file...
#
recvmsg=${homedir}/tmprecvmsg


	#
	# Message to the intended recipient
	#
printf "\
Date: ${rfcdate}\n\
From: ${admin}\n\
To: ${receivers}\n\
Subject: Inflex scan report [$xamimeLTid]\n\
\n\
This email has been sent to you from an email content scanning filter\n\
 located on the server [${server_name}].  If you have any queries relating\n\
 to this email, please direct them to ${admin}.\n\
 \n\
Report Details -----------------------------------------------\n\
Administrator Email Reply Address: ${admin}\n\
Email from: ${sender} has been blocked.\n\
Inflex ID: ${xamimeLTid} (use this to assist administrator in retrieving the email)\n\
Report Details -----------------------------------------------\n" >> ${recvmsg}

cat ${reportname} >> ${recvmsg}
printf "\nEnd.\n.\n" >> ${recvmsg}

cat ${recvmsg} | ${sendmail_bin} ${sendmail_flags} "${receivers}"

#END
