FormMail

Readme
Version: 1.92
Released: April 21, 2002

[ Matt's Script Archive ] [ Readme's ] [ FormMail ]

• Copyright and Header 

Overview 

Form Configuration 

- Necessary Form Fields

recipient

- Optional Form Fields 

subject 

return_link_url 

email

return_link_title

realname 

missing_fields_redirect

redirect 

background 

required

bgcolor

env_report

text_color 

sort 

link_color

print_config

vlink_color 

print_blank_fields

alink_color 

title 

 

Some of the possible uses of this script 

History

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Copyright and Header

##############################################################################
# FormMail                        Version 1.92                               #
# Copyright 1996-2002 Matt Wright mattw@worldwidemart.com                    #
# Created 06/09/95                Last Modified 04/21/02                     #
# Matt's Script Archive, Inc.:    http://www.worldwidemart.com/scripts/      #
##############################################################################
# If you run into any problems while trying to configure this scripts, help  #
# is available.  The steps you should take to get the fastest results, are:  #
#       1) Read this file thoroughly.                                        #
#       2) Consult the Matt's Script Archive Frequently Asked Questions:     #
#               http://www.worldwidemart.com/scripts/faq/                    #
#       3) If you are still having difficulty installing this script, send   #
#          e-mail to: scripts-help@tahoenet.com                              #
#          Include any error messages you are receiving and as much detail   #
#          as you can so we can spot your problem.  Also include the variable#
#          configuration block that is located at the top of the script.     #
#                                                                            #
# Hopefully we will be able to help you solve your problems.  Thank you.     #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1995 - 2002 Matthew M. Wright  All Rights Reserved.              #
#                                                                            #
# FormMail may be used and modified free of charge by anyone so long as this #
# copyright notice and the comments above remain intact.  By using this      #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from its use.                                                  #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.  In all cases copyright and header must remain intact #
##############################################################################

Overview

FormMail is a universal WWW form to E-mail gateway. There is only one required form input tag which must be specified in order for this script to work with your existing forms. Other hidden configuration fields can also be used to enhance the operation of FormMail on your site. The end of this file has a history that will explain the various changes FormMail has made throughout its lifetime. Version 1.91 is an update attempting to get rid of the worst problems that have been made public in:
http://www.monkeys.com/anti-spam/formmail-advisory.pdf
Version 1.92 fixed a couple more bugs, which you can read about in the history located at the end of this file.

The script, FormMail.pl, needs to be placed in your server's cgi-bin and the anonymous WWW user must have the ability to read/execute the script. If you do not have access to your server's cgi-bin, yet you can execute cgi scripts, you may want to try adding a .cgi extension to the FormMail.pl, renaming it to FormMail.cgi. This is probably the more common option.

Form Configuration

The action of your form needs to point towards this script (obviously), and the method must be POST  in capital letters. Version 1.5 of FormMail offers many new ways to code your form to tailor the resulting HTML page and the way the script performs. Below is a list of form fields you can use and how to implement them.

 

Necessary Form Fields

There is only one form field that you must have in your form, for FormMail to work correctly. This is the recipient field.

 

Optional Form Fields

Any other form fields that appear in your script will be mailed back to you and displayed on the resulting page if you do not have the redirect field set. There is no limit as to how many other form fields you can use with this form, except the limits imposed by browsers and your server.
 
 

Some of the possible uses of this script

  1. You want to have a form that will be mailed to you, but aren't sure how to write the CGI script for it. 

  2. You are the webmaster of your site and want to allow users to use forms, but not to have their own cgi-bin directories, which can cause security risks to your system. You can set this script up and then allow all users to run off of it. 

  3. Want to have one script to parse all of your html forms and mail them to you. 

 

History
Version 1.0 06/11/95 This script was created.
Version 1.1 08/03/95

A major hole in the script which allowed users to run commands under your server's uid was disabled, thanks to Paul Phillips who noticed the error.

The ability to redirect the user to a specified HTML file after they filled out a form was added.

Version 1.2 09/23/95

If the form field is one of the required or optional 'special' fields, such as redirect, recipient, subject, email, realname, etc... the script will not print these fields to either your mail message or to the user's screen when they are returned to a generic form response. It helps you so that things do not get duplicated.

Version 1.3 01/21/96

Much needed update finally completed

Added form fields: env_report, bgcolor, background, link_color, vlink_color, title, text_color, return_link_title, return_link_title, and required.

Security hole, which allowed any user on any system to bum off of your formmail script, has been plugged up with the @referers variable.

Report style in return html and e-mail touched up a bit.

Version 1.4 01/23/96

Added options: sort, alink_color

Fixed a few bugs from Version 1.3, namely the fact that the link_colors weren't working well.

FormMail now supports both the GET and POST methods.

Version 1.5 02/05/96

Sorting of Fields in E-Mail Response Fixed.

print_config option added.

Version 1.6 05/02/97

Sorting of fields by default was fixed to now sort in the order the fields are passed to FormMail from the web browser, which is usually the same order as they appear in the HTML form.

The sort order: directive, env_report and print_config parsing routines were made to better compensate for line breaks and extra spaces in input for ease of use.

Redirect error causing the redirect option to incorrectly work with https (secure servers) was fixed.

Output of non-filled in form fields suppressed.

E-mail addresses checked for correct syntax if designated a required field.

Fields only printed if they contain a value or if the print_blank_fields option is set to 1.

Missing_fields_redirect added so you can route users who don't completely fill out the form to a pre-made HTML page.

Parts of code optimized, especially in respect to the way config variables are handled.

Version 1.7
07/27/01
Added in @recipients to defeat spamming attempts.
Added in @valid_ENV to allow administrators to specify what environment variables can be sent.
Version 1.8 08/02/01

Fixed the recipients code to allow multiple recipients using the 'recipients' form field and commas.  Under certain cases in v1.7, spam could still get through by appending legit recipient to the list of intended spam victims.

Moved send_email subroutine in front of return_html as many people reported their web server would kill the FormMail process after the redirect command was issued and no e-mail would be sent.

Version 1.9 08/03/01 Added in a further anti-spam check which would take advantage of newline characters in the subject to send invalid e-mail.

Removed a restriction when checking e-mail addresses for validity that required a 2 - 3 character domain extension.  With the new TLD's becoming available, it can no longer apply.
Version 1.91 04/19/02 The same vulnerability that was patched in 1.9 with the subject field still existed in the email and realname fields. Newline characters are no longer allowed in any fields that are placed in the header of the message.

Much stronger default regular expression checking in the @recipients array is now implemented.  This will combat the % hack and other known exploits.

The options for sendmail were moved into the $mailprog variable and -i was added so that single periods on a line will not cause the end of the message.

Version 1.92 04/21/02 Removed cross-site scripting vulerabilities by converting all <, >, & and " into their HTML equivalents when displayed on a web page. These characters are left intact in the e-mail message.
 
Now removes any null bytes from form input.

Fixed field recognition so that '0' is now a valid input.  Supposedly fixed in v1.6.

Fixed print_blank_fields.
 

[ Matt's Script Archive ] [ Comment Form ] [ CGI/Perl Cookbook ] [ Advertising ]

Matt Wright - mattw@worldwidemart.com
© 1995 - 1998 Matt's Script Archive, Inc.

 

Comments or questions regarding OneNet: webmaster@onenet.net

Copyright 2000-2001 by OneNet®