#!/usr/bin/perl # # mail-form cgi # # Perl Web form processing script. Emails the data # to the recipient. # # This should be the proper location of sendmail on your system: $mailprog = '/usr/lib/sendmail'; # this should be your email address: $recipient = 'bxd@purdue.edu'; # 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 convert 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: Form Information\n\n"; print MAIL $postinput; print MAIL "\n\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 completing the form

$postinput
... has been mailed to the appropriate person.

EndHTML # the end.