#! /usr/local/bin/perl #---------------------------------------------------------------------- # Form-mail.pl, by Reuven M. Lerner (reuven@the-tech.mit.edu). # This package is Copyright 1994 by The Tech. # Packaged Modified to mail any form to you by Matt Wright # (mattw@alpha.pr1.k12.co.us) # Modified to include default comment form by David Efflandt # (efflandt@xnet.com) # Form-mail 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. # Form-mail 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. # For a copy of the GNU General Public License, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # ------------------------------------------------------------ ###################### # General Form Mail Script To Work With Any Fields # For any form using POST method or built-in comment/request form. # Created 11/19/95 Last Modified 12/31/96 # Define Variables for your system $mailprog = '/usr/lib/sendmail'; $recipient = 'yourname@yournet.com'; $nickname = 'Bob'; # nickname or company name $homepage = '/~yourname/index.html'; ###################### # Necessary Fields in HTML Form: # recipient = dummy hidden form variable to detect hacking (not required) # username = the remote users email address for replies (required) # realname = the remote users real identity # subject = subject line of email response # Get remote host $ip_address = $ENV{'REMOTE_ADDR'}; @numbers = split(/\./, $ip_address); $ip_number = pack("C4", @numbers); ($host) = (gethostbyaddr($ip_number, 2))[0]; # Create default comment form on GET &make_form unless ($ENV{'REQUEST_METHOD'} eq "POST"); # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @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; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($FORM{'redirect'}) { print "Location: $FORM{'redirect'}\n\n"; } else { # Print Return HTML &begin_html("Thank You"); print "
$recipient\n); print qq(
[ $nicks Home Page );
print qq(| Previous Page ) if ($referer);
print "]\n";
}
#subroutine make_form
sub make_form {
# Get page that called form
$referer = $ENV{'HTTP_REFERER'};
&begin_html("Comments for $nickname");
print < Please enter your comments or request for $nickname below
and press the submit button.
Check that your full Email address is valid if expecting a response.
Comment/Request Form
NEW_FORM
&end_html;
exit;
}