#!/usr/local/bin/perl
#FILE: email_basic.pl - Version 1.32
#
# This perl script generates both the HTML form and email message
#people wish to send you. This script requires "sendmail" to run.
#
# To call this script, just call it as you would any other php
#script you have on your system. Example:
# http://www.domain.com/cgi-bin/email_basic.pl
#
#REQUIREMENTS:
# 1) This script expects its name to be "email_basic.pl". On some systems, you may need
#to change the file extension to ".cgi" depending on how your system is configured.
# 2) Sendmail is required
# 3) The standard CGI module is required
# 4) You should have a directory specified where perl stores file
#attachments temporarily. When this script terminates, the attachments
#should be deleted from your system by this script.
#
#ADDITIONAL FEATURES:
# 1) Dynamically specify the "subject" field through the query string. For example:
#http://www.yourdomain.com/cgi-bin/email_advanced.pl?subject=hello_world
#will cause the phrase "hello_world" to automatically show up as the subject for the email
# 2) Dynamically specify the "to" field through the query string. For example:
#http://www.yourdomain.com/cgi-bin/email_advanced.pl?to=someone@somewhere.com
#will cause the email to override the default destination address. Great feature if you need
#to send a certain form submittal to another email address
# 3) Dynamically specify the "from" field through the query string. For example:
#http://www.yourdomain.com/cgi-bin/email_advanced.pl?from=webmaster@thiscomputer.com
#will cause the email to override the default from address. Great feature if you want
#the email to come "from" another email address
# 4) Any combination of the above. For example:
#http://www.yourdomain.com/cgi-bin/email_advanced.pl?subject=hello&from=webmaster@thiscomputer.com
# 5) Multiple file attachments. The ability to add multiple file attachments instead of just one
# 6) Limit the file upload size. Can specify if there are any limitations to the file upload size, and
#if so, how big the allowed files are to be.
# 7) Style sheets. The ability to set (or link in) style sheet definitions to customize your
#HTML text to look like it does on the rest of your site!
# 8) Restrict file uploads by file type! Choose which extensions you want to allow to be uploaded!
#
####
# If you want any of these additional features, you need to purchase the "advanced" version
#of this email script. Go to http://www.davelozinski.com/scripts/email for the juicy details. :)
####
#
# Finally, this "basic" code is free, and comes with absolutely NO
#warranties, either expressed or implied. Feel free to do what you want
#with it. Feel free to build upon it. If you did not get this code
#from http://www.davelozinski.com, you don't have the original.
#
#REVISION HISTORY:
# 06/03/02 Version 1.32 - Corrected a "buffer"
# attachment bug.
# 05/15/02 Version 1.31 - minor code enhancement
# 04/25/02 Version 1.3 - no modifications
# 02/01/02 Version 1.2 - minor modifications
# 09/28/01 Version 1.1
# 08/01/01 Original Version
#
#CONTACT INFORMATION:
# http://www.davelozinski.com/cgi-bin/email_lozinski.pl
#
#Begin the customizable configurations:
#The title of the web page and the text on the "submit" button
$TITLE = "Send Me Email!";
#The background color of the web page, the normal text color, and the
#text color for the information that is required. Note that these can
#either be in hexidecimal format, or words as the settings below show.
#If you specify the color code in hex, it expects a leading '#'
#pound sign.
$BGCOLOR = "#000000";
$TEXT_COLOR_NORMAL = "#0088FF";
$REQUIRED_TEXT_COLOR = "yellow";
#The URL to a background picture for the web pages.
$BACKGROUND_URL = "";
#The URL to the executable directory where this script is located.
#DO NOT put a trailing slash '/' character!
$CGI_DIR = ".";
#Set to "1" if you want the optional fields shown in the email form.
#Set to "0" (zero) otherwise.
$SHOW_OPTIONAL_FIELDS = 0;
#The email address where you want all the email from this page sent to if
#no destination email is supplied by the "to" parameter. NOTE THE BACKSLASH
#CHARACTER "\" BEFORE THE "@" CHARACTER!
$DESTINATION_EMAIL = "destination_address\@some_domain.com";
#The email address that will be placed in the "from" field of all emails sent back to
#the end user.
$FROM_EMAIL = "return_address\@yourdomain.com";
#Set to "1" if you want the optional file upload field shown in the email form.
#Set to "0" (zero) otherwise.
#BE CAREFUL WHEN USING THIS FEATURE AS PEOPLE COULD POTENTIALLY EMAIL YOU
#VIRUSES! Of course, this is true of any email you receive, but allowing
#email attachments from strangers greatly increases this risk.
$SHOW_ATTACHMENT_FIELD = 1;
#Need to set the path to "sendmail"
$SENDMAIL = "/usr/bin/sendmail";
#Define the directory where uploaded files are
#temporarily stored for attaching to the outgoing email.
#You need to provide a trailing slash "/" character!
#Also note that this directory should have "world" write permissions
#so this script can actually save the file uploads!
$TEMPPATH = "/tmp/";
#####################################################################
######## NOTHING FROM HERE DOWN SHOULD NEED TO BE CONFIGURED ########
#####################################################################
######## Main body of code ########
use CGI;
my $in = new CGI;
&StartHTML;
if (!$in->param("mail")) {
&PrintForm;
} else {
if (!(&check_form_data)) {
if (&send_mail) {
&reply_to_user;
} else {
print ("Your email was not sent.
\n");
}
}
}
&FinishHTML;
exit(0);
######## perl functions ########
########################
#sub StartHTML
#This function prints the start of the feedback form web page.
########################
sub StartHTML {
print ("Content-type: text/html\n\n");
print ("