#!/usr/bin/perl ############################################################################## # Cliff's Form Mailer Version 1.0 # # Copyright 1998 Shaven Ferret Productions # # Created 6/4/98 # # Available at http://www.shavenferret.com/scripts # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998 Shaven Ferret Productions All Rights Reserved. # # # # This script can be used\modified free of charge as long as you don't # # change this header thing, or the part that gives me credit for writing # # script in the e-mail. If you really need to remove this part, go to # # http://www.shavenferret.com/scripts/register.shtml . By using this script # # you agree to indemnifyme from any liability that might arise from its use. # # In simple English, if this script somehow makes your computer run amuck # # and kill the pope, it's not my fault. # # # # Redistributing\selling the code for this program without prior written # # consent is expressly forbidden. # ############################################################################## # Enter the location of sendmail. $mailprogram = "/usr/sbin/sendmail -t"; # Enter the fields that are required. They should each be in quotes and # separated by a comma. If no fields are required, change the next line # to @required = (); @required = ('email','subject'); # Enter your e-mail address. Be sure to put a \ in front of the @. # (user@domain.com becomes user\@domain.com) $youremail = "cdorder\@saintsaens.com"; ############################################################################## # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ############################################################################## # Put the posted data into variables read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; $FORM{$name} = $value; } # Check for all required fields foreach $check(@required) { unless ($FORM{$check}) { print "Content-type: text/html\n\n"; print "Missing Information\n"; print "

Missing Information


\n"; print "I'm sorry, but it would appear that you've forgotten to\n"; print "fill out the $check field. Please click\n"; print "back and try again.\n"; print "\n"; exit; } } # Check the senders email if ($FORM{'email'}) { unless ($FORM{'email'} =~ /\w+@\w+.\w+/) { print "Content-type: text/html\n\n"; print "Bad E-mail\n"; print "

Bad E-mail


The e-mail address that you've\n"; print "entered, $FORM{'email'}, is invalid. Please click back and\n"; print "try again.\n"; exit; } } open (MAIL,"|$mailprogram"); print MAIL "To: $youremail\n"; print MAIL "From: $FORM{'email'}\n"; print MAIL "Subject: CD order from Saint Saens.com website\n"; print MAIL "Hello. The following information has been submitted:\n\n"; print MAIL "$FORM{'subject'}\n"; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; unless ($name eq "response" || $name eq "email" || $name eq "subject") { print MAIL "$name: $value\n"; } } close MAIL; if ($FORM{'response'} && $FORM{'email'}) { open (RESPONSE, $FORM{'response'}); @response = ; close(RESPONSE); open (MAIL,"|$mailprogram"); print MAIL "To: $FORM{'email'}\n"; print MAIL "From: $youremail\n"; print MAIL "Subject: $FORM{'subject'} -- Autoresponse\n"; foreach $line (@response) { print MAIL "$line"; } print MAIL "Thank you very much for placing an order at www.jasperwood.net\n"; print MAIL "We will send you an e-mail confirming the total\n"; print MAIL "cost of your order.\n"; close MAIL; } print "Content-type: text/html\n\n"; print "Thank you!\n"; print "

Thank you!


Thanks for your input!

\n"; if ($FORM{'response'} && $FORM{'email'}) { print "You should receive an autoresponse shortly.

\n"; } print "Your order has been accepted.

\n"; print "Please continue to visit www.saintsaens.com\n";