#!/client/bin/perl

print "Content-type: text/html\n\n";

@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
  $pair =~ tr/+/ /;
  $pair =~ s/%(..)/pack("c",hex($1))/ge;

  $pos = index($pair,"=");

  $entry{substr($pair,0,$pos)} = substr($pair,$pos+1);
}

# prevent hacking of mail 

$entry{'my_name'} =~ s/\;/ /ge;
$entry{'my_name'} =~ s/\|/ /ge;
($entry{'my_name'}, @dummy ) = split(/ /, $entry{'my_name'});
($nx, $na, @dummy ) = split(/@/, $entry{'my_name'});
$entry{'my_name'} = $nx . "@" . $na;

open(MAIL, "| /bin/mail $entry{'my_name'}");
print MAIL<<END_OF_PRINT;
mail message is being sent from the www server.

here is a list of important information.

REMOTE_HOST: $ENV{'REMOTE_HOST'}
name: $entry{'my_name'}
status: $entry{'my_status'}

--- end of message
END_OF_PRINT
close(MAIL);

print<<END_OF_PRINT;
mail message successfully transmitted (as far as I am concerned.)<br>

REMOTE_HOST: $ENV{'REMOTE_HOST'}<br>
name: $entry{'my_name'}<br>
status: $entry{'my_status'}<br>

END_OF_PRINT

exit;

/* -- output ---

Date: Fri, 3 Jan 97 12:00:54 +0100
X-Ph: V4.4@rumms
From: infoad@suse.rz.uni-mannheim.de (WWW-Verwalter)
Apparently-To: kredel@rz.uni-mannheim.de

mail message is being sent from the www server.

here is a list of important information.

REMOTE_HOST: krum.rz.uni-mannheim.de
name: kredel@rz.uni-mannheim.de
status: 

--- end of message

-- */