#!/usr/bin/perl
#
#
# Read in the email from stdin
#

while ( <> ) {
	$line = $_ ;
	chomp($line) ;
	if ( $line =~ /^From:/       ) { $from    = $line }
	if ( $line =~ /^To:/         ) { $to      = $line }
	if ( $line =~ /^Cc:/         ) { $cc      = $line }
	if ( $line =~ /^Subject:/    ) { $subject = $line }
	if ( $line =~ /^Date:/       ) { $date    = $line }
	if ( $line =~ /^X-CLAMAV:/   ) { $virus   = $line }
	if ( $line =~ /^Message-ID:/ ) { $id      = $line }

}

#
# The following was a bad idea because the user may not be local.
# Maybe we should check that $to and $cc refer to a local user?
# For now, just sent the warming to local root.
#
##
## Only add the following if they are defined so as to not put
## a blank line in the header and thus prematurely cut the head
## from the body of the message
##
#
#$report = "" ;
#if ( $to  ) { $report .= $to  . "\n" }
#if ( $cc  ) { $report .= $cc  . "\n" }
#

$report = "" ;

$report .=<<EOF ;
To: root\@virtualblueness.net
From: root\@virtualblueness.net
Subject: THE VIRUS SCANNER

The following email:

	$from
	$to
	$subject
	$date
	$id

was quarantined because our virus scanner found that it contained the
following virus or viruses:

	$virus

EOF

open(SM, "|/usr/sbin/sendmail -oi -t") ;
print SM $report ;
close(SM) ;


