#!/usr/local/bin/perl 

$mailprog = '/usr/bin/mail';
$recipient = 'thomas.mccann.portland.or@worldnet.att.net';

print "Content-type: text/html\n\n";
print "<Head><Title>Oregon Operation Lifesaver</Title></Head>";
print "<Body><H1>Thank you for signing the Guest Book . . . </H1></Body>";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $FORM{$name} = $value;
}

 if ($FORM{'e-mail'} eq "") {$FORM{'e-mail'} = '';}
 if ($FORM{'name'} eq "") {$FORM{'name'} = '';}

open (MAIL, "|$mailprog $recipient $FORM{'e-mail'} $FORM{'NAME'}") || die "Can't open $mailprog!\n";
print MAIL "This is a Guest Book entry from $FORM{'name'} who is reachable at $FORM{'e-mail'}:\n";
print MAIL "\n";
print MAIL "$FORM{'name'}'s organization is: $FORM{'organization'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "\n";
print MAIL "Here are the topics $FORM{'name'} would like to know more about:\n";
print MAIL "\n";
print MAIL "$FORM{'topics'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "\n";
print MAIL "Here is how $FORM{'name'} learned about Oregon Operation Lifesaver:\n";
print MAIL "\n";
print MAIL "$FORM{'sources'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
close (MAIL);

print "Your input will assist us in our continuing efforts to develop and improve <STRONG>The Webmaster's Workshop</STRONG>.<P>\n";
print "Return to the <A HREF=\"http://trainweb.com/olif/index.htm\">OL Home Page</a>\n";

