Mail Form Handler Help
OverviewThe Mail Form Handler (mail_form.pl) is a generic CGI script designed to email HTML form input to a specified user or users. All your forms can point to a single instance of the script because the script can support any number of HTML forms while providing customizable output for each. To use the script, all you need is an HTML form. The script uses the "name" and "value" attributes of special form <input> tags to collect variable data. Many of these fields are of type="hidden", such as the "Recipient Address". This means that users don't see the field in their browser but the name/value pair for the field is passed to the script when they submit the form. Other fields can be hidden or can be filled in by the form submitter as desired, such as the "Email Subject Line". None of the special name/value pairs are returned in the generated email/results page (except the Full Name special field). However, all of the special fields are used to generate the email and to return the results page properly. (Note: To exclude the Full Name field from the results table as well, prepend the string "exclude;" to the specified Full Name value. See below.) The <form> tag in your HTML form should point to the script location and should use the POST method. For example: <form method="post" action="http://www.someserver.com/cgi-bin/mail_form.pl"> Server Requirements
unix servers: windows 2000 iis servers: Note on sendmail: The Mail Form Handler script points to the sendmail binary/executable in two places - both must be modified if your sendmail is in a non-default location. Point your browser at the HTTP location of the script to see if the script has found an installation of sendmail on your server and to see whether you need to change the two lines in the script that point to it. Installing the ScriptTo install the script, first download the script and save it as a file on your hard drive. What you should have is just a text file on your disk. Copy this text file to your HTTP server and place it in the cgi-bin, scripts, or an arbitrary directory. Where you put the file depends on the server setup with regard to executing scripts. See the troubleshooting section below for more information. Once the script is in the correct location, make sure the permissions are set to world read and world executable. Make sure that the perl installation and sendmail installation are correct and that the script points to the right locations to access these components. Lastly, make sure your HTML form "action" tag points to the absolute or relative HTTP location of the mail_form.pl or mail_form_win.pl script. TroubleshootingHere are some common problems with implementing the script:
Note: ALL names (and where indicated, values) are CASE SENSITIVE! Recipient Address - The email address(es) to send the form submission results to. Multiple addresses can be specified as a comma-separated list. THIS IS THE MOST IMPORTANT FIELD. IF YOU DON'T SPECIFY YOUR EMAIL ADDRESS HERE, THE EMAIL WILL BE SENT TO THE DEFAULT ADDRESS. This field is usually type=hidden.
Example (multiple addresses): <input type="hidden" name="Recipient Address" value="address1@example.com, address2@example.com"> Email Address - Used as the return address in the email. This is usually a user-entered value.
Cc Address - Specifies address(es) to include on the Cc: line of the email. Multiple addresses should be specified as a comma-separated list. This can be a user-entered or predefined address or comma-separated list of addresses.
Auto Cc - Allows you to Cc the user (as defined by the Email Address "special" field) on the generated email. Value (case sensitive) should be either "Yes" (Cc user) or "No" (don't). This field is usually type=hidden.
Full Name - Used as the parenthetical full name in the return address of the email. This is the only special field that is returned in the results table. To exclude it (useful if you're using a predefined generic string), prepend the string "exclude;" (case sensitive, include the semicolon but not the quotes) to the value. This can be a user-entered value or a predefined generic string (e.g., "Feedback Results").
Example (with result hidden): <input type="hidden" name="Full Name" value="exclude;Form Submission"> Email Subject Line - Specifies the subject line of the generated email message. This can be a user-entered value or a predefined generic string.
Email HTML - Specifies whether the generated email should be sent using plain text or HTML format. Value (case sensitive) should be either "Yes" (send HTML) or "No" (don't). This field is usually type=hidden.
Background Color - Defines the background color for all pages generated by the Mail Form Handler. Any valid color name or #RRGGBB value is acceptable (for example, "white" and "#FFFFFF" both produce a white background). This field is usually type=hidden.
Link Color - Defines the link color for all pages generated by the Mail Form Handler. Any valid color name or #RRGGBB value is acceptable. This field is usually type=hidden.
ActiveLink Color - Defines the active link color for all pages generated by the Mail Form Handler. Any valid color name or #RRGGBB value is acceptable. This field is usually type=hidden.
VisitedLink Color - Defines the visited link color for all pages generated by the Mail Form Handler. Any valid color name or #RRGGBB value is acceptable. This field is usually type=hidden.
Text Color - Defines the color of the text on all pages generated by the Mail Form Handler. Any valid color name or #RRGGBB value is acceptable. This field is usually type=hidden.
Toggle Graphics - Toggles graphics usage (Required Graphic and Graphic special fields). Value should be either "On" (graphics are used) or "Off" (graphics are not used). This field is usually type=hidden.
Required Graphic - Full or relative URL of the desired "required fields" graphic (generated when any required fields are not filled in). This graphic inherits any alignment properties specified by the Response Page Title special field. This graphic is only shown if the Toggle Graphics special field is set to On. This field is usually type=hidden.
Graphic - Full or relative URL of the desired header graphic. Use a full URL if the Email HTML option is set to Yes. This graphic is only shown if the Toggle Graphics special field is set to On. This field is usually type=hidden.
Magic Word - Specifying a magic word allows you to make input type=Select fields required while still having text as the first element in the drop down list (for example, "Select One"). This field is usually type=hidden.
Response Page Title - Text used for the title and heading of the results page. To center the heading elements on the page (graphic and heading text), prepend the string "center;" (case sensitive, include the semicolon but not the quotes) to the title value. Default is left aligned. This field is usually type=hidden.
Example (centered): <input type="hidden" name="Response Page Title" value="center;Submission Received"> Greeting - Short blurb of thanks. Use "*" in the value to denote a new paragraph (<p>) This field is usually type=hidden.
Return URL - Full URL to use for the link to be displayed on the results page. Note that you can include a target specification at the end of this URL (see example). You'll be disappointed if you don't use the Return Link Text special field in conjunction with this one. This field is usually type=hidden.
Example (with target spec): <input type="hidden" name="Return URL" value="http://www.servername.com/home/index.html target=_top"> Return Link Text - Text to use for the link to be displayed on the results page. You'll be disappointed if you don't use the Return URL special field in conjunction with this one. This field is usually type=hidden.
Show Results - Tells the script whether to display the form values onscreen for the user when the form is submitted. Value (case sensitive) should be either "Yes" (show them) or "No" (don't). This field is usually type=hidden.
Show Blanks - Tells the script whether to display form name/value pairs in the results if the value is null (blank). Value for Show Blanks (case sensitive) should be either "Yes" (show them) or "No" (don't). This field is usually type=hidden.
Debug Flag - Tells the script to print debug information to the generated HTML response page. Value (case sensitive) should be either "Yes" (show debugs) or "No" (don't). This field is usually type=hidden and is only used for troubleshooting purposes.
Default values for a particular instance of the script can be viewed by pointing at the script itself using your browser. For example, on a server www.example.com, if the script is in a directory called /cgi-bin and the filename is mail_form_handler.cgi, you would point at http://www.example.com/cgi-bin/mail_form_handler.cgi to view the built-in help file, which includes the default values for each field. Try it out (mail_form.pl.cgi on server www.employees.org): mail form handler built-in help file In version 4.0 and later, the script can limit form data submission to a user-specified list of domain names, IP addresses, or URLs, based on the HTTP_REFERER environment variable passed from the submitting form. While not foolproof, this feature provides basic protection against unauthorized use of an instance of the script on your server by some third party. HTTP referer checking is disabled by default. YOU MUST MODIFY THE SCRIPT ITSELF TO ENABLE THIS FEATURE AND MODIFY THE ALLOWED HTTP REFERER LIST. In other words, this is not a setting that is passed from the HTML form to the script. The process is pretty straightforward, and the script is well-commented to help you make the proper changes. To enable this feature:
Only referring URLs that match one of the strings you enter in the Allowed List will be permitted to submit form data to the script. Any others will receive an error message. Make sure you include any possible alternate domain names you might want to use, and be sure to remove the "dummy" domain names and IP addresses in the script by default. The following examples illustrate how the Allowed List might look after you modify it : @httpAllowedList = ("host.example.com", "http://host", "example.com", "http://10.99.113.4", "http://another-host.example.com", "http://another-host/", "www.example.net", "http://example.net", "http://www.example.org/~user/files/forms/my_html_form.html"); In version 4.0 and later, the script supports the option to send the generated email message in HTML format rather than in plain text. This is done using the HTML Email special form field. This is pretty self-explanatory. Obviously, there are probably some security concerns about sending & receiving HTML in your email (I suggest making sure you have a virus checker on your system that detects malicious ActiveScript, Java, JavaScript, and so on). The one gotcha with sending HTML email is that if you are using the "Graphic" special form field, make sure you specify the complete URL of the image file, not a relative location, otherwise you will see a broken image in the HTML email.
In version 3.0 and later, the script checks the email address format for the Recipient Address, Email Address, and Cc Address fields. An email address is rejected if any of the following applies:
In version 4.0 and later, the script accomodates email addresses using "anti-Spam" format, that is, with the word "at" instead of the symbol "@" between the username and the domain name. This prevents email harvesters from gleaning your email address from the "Recipient Address" or "Cc Address" fields in your HTML forms. As an example, suppose your email address is "nobody@example.com". You can use the following HTML for the "Recipient Address" field to protect your email address: <input type="text" name="Recipient Address" value="nobody at example.com"> To specify a required field, use a "*" after the input tag "name" attribute -- this denotes a field that must be completed before the form will be processed. In the following example, users must fill in their phone number before the form is accepted.
If you are using required "select" lists (that is, <select name="some_name*"> elements where you want to force the user to make a choice), use the "*" to identify the select list as required and use the "Magic Word" hidden field to have a text line (for example, "Select One") as the default option ("option selected"). If you do not specify a Magic Word, the default option must be blank. This field would in most cases be type=hidden. Here is an example:
<select name="Select List*">
<option>Choice One <option>Choice Two <option>Choice Three It is important that you specify the "Magic Word" input field ONLY ONCE in your HTML form. Specifying multiple Magic Word elements (whether using the same or different Magic Words) will return unexpected results. This means that you must use the same Magic Word throughout a given form, regardless of how many "select" lists or other multiple choice fields (radio buttons, etc) you have. Making Radio Button input fields required is a bit kludgy, because no value is passed to the script if no radio button is selected, and if you use the "checked" attribute on one of the buttons, then the requirement for a response is satisfied! The workaround is to include a radio button that utilizes the "Magic Word" as its value. Note that you must include an asterisk (*) after the name for each radio button. Here is an example:
<input type="radio" name="Required Radios*" value="Select One" checked> <input type="radio" name="Required Radios*" value="Option 1"> <input type="radio" name="Required Radios*" value="Option 2"> Unfortunately, making Checkboxes required using the same method is even kludgier, because the user has to uncheck the Magic Word checkbox as well as check one or more other checkboxes (as opposed to the radio buttons, where only one choice is possible at any given time). Mail Form Handler (mail_form.pl) by Tim Stevenson ReadParse subroutine by Steven E. Brenner This script may be distributed freely as long as this message remains intact. DisclaimerThe Mail Form Handler is provided as-is. I shall not be held responsible for its performance, nor the manner of its use by another party, in any respect. In addition, use of this script is subject to the Privacy & Usage Policy.
|