#!/usr/local/bin/perl
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Stray's General Purpose Form Mailer 17 September 1998
# info@stray.ch Version 1.1
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script will take the input of any HTML form and send it to a list
# of recipients. Compulsory fields must be filled in or the error page will
# be displayed. When successful, mail will be sent, omitting empty fields,
# arranging the field results in a properly manner.
#
# The original version of this script can always be foud at
# http://crypt.stray.ch/scripts.html
#
# HTML definitions:
# -----------------
# -
# -
# -
# -
#
# -
# This is a special field name to insert an empty line in the mail
# message; useful to separate various information groups in a form.
#
# - Fields with their names starting with a "#" sign are compulsory,
# i.e. they must be filled out in order for the form to be sent; else,
# the error page as defined in the hidden field will be loaded.
# e.g. " will be compulsory.
#
# - Any field called "email" will be used for the reply-to address of the
# mail sent. You can use a user field for "email", so the mail will
# have the correct reply-to address of the person filling in the form.
# If omitted, a standard reply-to address will be given instead.
#
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# =-=-= The happy variable setting part -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mailprog = '/usr/lib/sendmail'; # the mail programm on your server
$date = `/bin/date`; chop ($date); # time and date
$emptyline = "\n"; # set this to change the separator
# =-=-= Converting server input into name / value pairs -=-=-=-=-=-=-=-=-=-=
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# =-=-= Checking hidden fields for completeness -=-=-=-=-=-=-=-=-=-=-=-=-=-=
if ( (!$FORM{'error'}) || (!$FORM{'thanks'}) ) {
print "Content: text/html\n\n";
print "