#!/usr/bin/perl #************************************************************************ # TD Form-Mailer 1.0 * # Scripted by T.David * # tdformmailer.cgi * # Original Creation: 9/27/99 * # Last Modified: 9/27/99 * # * # Available at http://www.tdscripts.com * # * # COPYRIGHT NOTICE * # Copyright 1999 KMR Enterprises All Rights Reserved * # * # By using this script you agree to indemnify us from any liability * # that might arise from its use. This copyright notice MUST * # remain in tact in order to legally use this script. Removal and/or * # modification of the copyright notice voids registration. * # * # You do *NOT* have permission to redistribute or sell the code for * # this program. This script is *freeware* as long as the linkback * # is kept in place. * # * # *****YOU MUST MODIFY THE VARIABLES BELOW******************************* # change to your DOMAIN, make sure to include a trailing slash / $mydomain = "http://www.theodora.com/"; # change to location of sendmail on your server (try the default setting 1st) # then try this one if that doesn't work: "/usr/lib/sendmail -t" $sendmailpath = "/usr/sbin/sendmail -t"; # change to YOUR email address, be sure to use the \ before the @ or script # will error out OR set to "" to let the person filling out the form # determine where the form will be sent $emailresultsto = "photius_fb\@yahoo.com"; # change to name you want to show in the 'to' field, if you don't care # about your email showing then put your email address here $yourname = "TDavid"; #************************************************************************ # Instructions for using tdformailer.cgi: # # 1. Upload this file via FTP in ASCII only to your cgi-bin # 2. Set permissions for script to chmod 755 tdformmailer.cgi # 3. Call tdformmailer.cgi from a form action tag in HTML # 4. You (or other party) will be emailed the results of the form. # 5. For more information please visit the website at: # # http://www.tdscripts.com/formmailer.html # #************************************************************************ ############################################################################ ### *** OPTIONAL SETTINGS *** YOU DO *NOT* HAVE TO CHANGE THIS *** ### ############################################################################ # if security option below is set to 'yes' then tdformmailer.cgi # can *ONLY* be run from forms within *YOUR* domain. Set this to 'no' # if you want to be able to run the script from any domain (default is no) $security_option = 'no'; ########################################################################## ########## Don't modify anything below this line ################# ########################################################################## $version = 'TD Form Mailer 1.0'; &parse_form; print "Content-type: text/html\n\n"; if ($security_option eq "yes") { &security; } else { &start; } sub security { $comingfrom = $ENV{'HTTP_REFERER'}; if ($comingfrom =~ m#^$mydomain#) { &start; } else { print "
$version can't be run from this location, sorry."; exit; } } sub start { $from = $formdata{'from'}; $email = $from; &validate_email; $to = $formdata{'to'}; if ($to eq "") { $to = $emailresultsto; } else { $email = $to; &validate_email; } $subject = $formdata{'subject'}; $contents = $formdata{'contents'}; $dropdownmenu = $formdata{'dropdownmenu'}; open(MAIL, "|$sendmailpath")|| &errormailwrite; print MAIL "To: $to \nFrom: $from\n"; print MAIL "Subject: $subject\n"; if ($dropdownmenu) { print MAIL "$dropdownmenu\n"; } print MAIL "$contents\n"; close(MAIL); print "Thank you. Your comments have been submitted as follows:"; if ($to ne $emailresultsto) { print "
To: $to \n"; } else { print "
To: $yourname\n";
}
print "
From: $from\n";
print "
Subject: $subject\n";
print "
$dropdownmenu\n"; print "
$contents\n"; print "
\n"; &td; } sub validate_email { if ($email) { if ($email =~ /^(\w{3,20})\@{1,1}\w{2,20}\.{1,4}\w{2,4}$/) { } else { print "
Sorry the email address appears to be invalid.";
print "
Please go back and re-enter your valid email address.";
print "
It must be in the format: myemail\@myisp.com "; &td; exit; } } } sub td { print "
Copyright 1999 Scripted by ";
print "TDavid\n";
print "
$version Available at TDscripts.com