File email-virus-notification.sh of Package clamsmtp

#!/bin/sh
#
# v0.3 (2005-01-13)
#
# Simple VirusAction script to get virus alerts via email from ClamSMTP.
# Depends on formail binary.
#
# Olivier Beyssac <ob@r14.freenix.org>
#
# Thanks to Colin McKinnon <colin@mms3.com> for the ``cat -v'' patch
#

[ -f /etc/sysconfig/clamsmtp ] && . /etc/sysconfig/clamsmtp

# notification defaults
snotify=${SENDER_NOTIFY:-no};
rnotify=${RECIPIENT_NOTIFY:-no};
pnotify=${POSTMASTER_NOTIFY:-yes};
pmaster=${POSTMASTER:-postmaster};
MAILTO="";

# formail should be in PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

LINE="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"


[ "$pnotify" = "yes" ] && MAILTO=$pmaster
[ "$rnotify" = "yes" ] && MAILTO=$RECIPIENTS","$MAILTO
[ "$snotify" = "yes" ] && MAILTO=$SENDER","$MAILTO
[ -z "$MAILTO" ] && exit 0;

{
 echo "Virus name:     $VIRUS"
 echo "Sender:         $SENDER"
 echo "Recipient(s):   $RECIPIENTS"
 echo "SMTP client:    $CLIENT"
 echo "SMTP server:    $SERVER"
 echo
 if [ "x$EMAIL" != "x" ] && [ -f $EMAIL ]
 then
	echo "Quarantined to: $EMAIL"
	echo
	echo Headers follow:
	echo $LINE
	formail -X "" < $EMAIL
	echo $LINE
 fi
}|cat -v|mail -s "Virus found in mail" $MAILTO 

logger -t virusnotify -p mail.error "notification sent to $MAILTO: Virus from $SENDER to $RECIPIENTS"