<PRE>
#!/usr/bin/perl

#-----------------------------------------------------------
# Form-mail.pl, by Reuven M. Lerner
# (reuven@thetech.mit.edu).
# This package is Copyright 1994 by The Tech.
# Packaged Modified to mail any form to you by Matt Wright
# (mattw@misha.net)
# FormMail is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation;
# either version 2, or (at your option) any later version.
   
# FormMail is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more
# details.

# Write the Free Software Foundation, 675 Mass Ave, 
# Cambridge, MA 02139, USA.
# If you would like to obtain a copy of the GNU GPL.
# ----------------------------------------------------------

####################################################
# FormMail
# Created by Matt Wright
# Created 6/9/95                Last Modified 9/23/95
# Version 1.2
# I can be reached at:          mattw@misha.net
# Scripts Archive a
#     http://www.worldwidemart.com/scripts/

# Define Variables
$mailprog = '/usr/lib/sendmail';
$date = `/usr/bin/date`; chop($date);

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 
# Split the name-value pairs
@pairs = split(/&amp;/, $buffer);

foreach $pair (@pairs){
   ($name, $value) = split(/=/, $pair);

   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
   $name =~ tr/+/ /;
   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;

   $FORM{$name} = $value;
}

if ($FORM{'redirect'}) {
   print &quot;Location: $FORM{'redirect'}\n\n&quot;;
}
else {
   # Print Return HTML
   print &quot;Content-type: text/html\n\n&quot;;
   print &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Thank You&lt;/title&gt;&lt;/head&gt;\n&quot;;
   print &quot;&lt;body&gt;&lt;h1&gt;Thank You For Filling Out This Form&lt;/h1&gt;\n&quot;;
   print &quot;Thank you for taking the time to fill out my feedback form. &quot;;
   print &quot;Below is what you submitted to $FORM{'recipient'} on &quot;;
   print &quot;$date&lt;hr&gt;\n&quot;;
}

# Open The Mail
open(MAIL, &quot;|$mailprog -t&quot;) || die &quot;Can't open $mailprog!\n&quot;;
print MAIL &quot;To: $FORM{'recipient'}\n&quot;;
print MAIL &quot;From: $FORM{'email'} ($FORM{'realname'})\n&quot;;
if ($FORM{'subject'}) {
   print MAIL &quot;Subject: $FORM{'subject'}\n\n&quot;;
}
else {
   print MAIL &quot;Subject: WWW Form Submission\n\n&quot;;
}
print MAIL &quot;Below is the result of your feedback form.  It was\n&quot;;
print MAIL &quot;submitted by $FORM{'realname'} ($FORM{'email'}) on $date\n&quot;;
print MAIL &quot;---------------------------------------------------------\n&quot;;

foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);

   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
   $name =~ tr/+/ /;
   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;

   $FORM{$name} = $value;
   unless ($name eq 'recipient' || $name eq 'subject' || $name eq 'email'
    || $name eq 'realname' || $name eq 'redirect')
      {
      # Print the MAIL for each name value pair
      if ($value ne &quot;&quot;) {
         print MAIL &quot;$name:  $value\n&quot;;
         print MAIL &quot;____________________________________________\n\n&quot;;
      }

      unless ($FORM{'redirect'}) {
         if ($value ne &quot;&quot;) {
            print &quot;$name = $value&lt;hr&gt;\n&quot;;
         }
      }
   }
}
close (MAIL);

unless ($FORM{'redirect'}) {
   print &quot;&lt;/body&gt;&lt;/html&gt;&quot;;
}
</PRE>