#!/usr/bin/perl # # mail-form cgi # © 2000 Jackie Hamilton - http://www.cgi101.com/ # # Quick and dirty Web form processing script. Emails the data # to the recipient. # # change this to the proper location of sendmail on your system: $mailprog = '/usr/sbin/sendmail'; # change this to your email address: $recipient = 'YOUR EMAIL ADDRESS'; # change this to your URL: $homepage = "http://www.cgi101.com/"; # everything below this shouldn't need changing. # # Print out a content-type for HTTP/1.0 compatibility print "Content-type:text/html\n\n"; # Get the input and grok it into something legible read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); $postinput = $buffer; $postinput =~ s/&/\n/g; $postinput =~ s/\+/ /g; $postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # Now send mail to $recipient open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; print MAIL "To: $recipient\n"; print MAIL "From: webserver\n"; print MAIL "Subject: Generic Form Reply\n\n"; print MAIL $postinput; print MAIL "\n\n"; print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n"; print MAIL "HTTP From: $ENV{'HTTP_FROM'}\n"; print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n"; print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n"; close (MAIL); # Print a thank-you page print < Thank you

Thank you for writing!

Thank you for your feedback. Return to our home page.

EndHTML # the end.