    =**************************************
    = Name: CGI Form-Mailer
    = Description:This simple CGI script all
    =     ows a webmaster to give his visitors a w
    =     ay to e-mail him from an HTML form. It u
    =     tilizes the server's mail transport agen
    =     t ( such as SENDMAIL ) and is fully cust
    =     omizable. That is, you can modify all pa
    =     rameters right from the HTML form itself
    =     ! This should be good news for those who
    =     are not CGI programmers.
    = By: Verite Donato
    =
    = Inputs:All parameters must be changed 
    =     from within the HTML document containing
    =     the form. An explanation follows:
    "redir" is a hidden field that specifies where the script should redirect the user after the message has been sent.
    "showFields" is a hidden field that specifies whether the script should print the HTML form fields along with the corresponding values.
    "to" should probably be hidden, but does not have to be. You should put here the e-mail address of the person to which the message should be sent.
    "from" is simply the e-mail address of the person from whom the message is sent.
    "subject" is a short string of text that specifies what the message is about.
    After "subject", you can put as many form fields as you want. They will simply become the body of the e-mail message.
    =
    = Returns:The user will be redirected to
    =     the page specified in the "redir" form f
    =     ield.
    =
    = Assumes:The only possible modification
    =     you might have to make is with the $mail
    =     erPath scalar variable. If
    your server doesn't use sendmail, you will need to change the contents of that variable to whatever mail agent your server does use.
    =
    =This code is copyrighted and has    = limited warranties.Please see http://w
    =     ww.Planet-Source-Code.com/vb/scripts/Sho
    =     wCode.asp?txtCodeId=267&lngWId=6    =for details.    =**************************************
    
    #!/usr/local/bin/perl
    $mailerPath = "/usr/sbin/sendmail -t";
    print "Content-type: text/html\n\n";
    $queryString = <STDIN>;
    @elements = split ( '&', $queryString );
    $idx = 0;
    foreach $item ( @elements ) {
    ($field, $value) = split ( '=', $item );
    $fields[$idx] = $field;
    $values[$idx] = $value;
    $values[$idx] =~ s/\+/ /g;
    $values[$idx] =~ s/%([a-fA-F0-9][a-dA-F0-9])/pack("C",hex($1))/eg;
    $idx++;
    }
    my $redir = $values[0];
    my $showFields = $values[1];
    open ( MAILPIPE, "|$mailerPath" ) or die "Error opening $mailerPath: $!\n\n";
    print MAILPIPE "To: $values[2]\nFrom: $values[3]\n";
    print MAILPIPE "Subject: $values[4]\n\n";
    for ( $i = 3; $i < $idx; $i++ ) {
    if ( $showFields ) {
    print MAILPIPE "$fields[$i] : $values[$i]\n";
    }
    else {
    	print MAILPIPE "$values[$i]\n";
    }
    }
    close ( MAILPIPE );
    print "<SCRIPT>location='$redir';</SCRIPT>";