Setting up FormMail

FormMail is a simple CGI script which takes input data from a web form and sends it via e-mail. To set up your form to use FormMail, set the form's action to "/cgi-bin/formmail".

You will also need to add an input field named "recipient" to your form, containing the e-mail address you want the form data sent to. Usually, this will be a hidden input field, so that it is not a visible part of the web page.

        <input type="hidden" name="recipient" value="username@domain.net">

FormMail will only send e-mail to addresses within the same domain as your website. You can specify more than one recipient address, separated by commas.

Config Fields

There are several input fields which FormMail recognizes and can use to customize its behaviour. These config fields are optional. Usually, they will be hidden input fields, so that they are not a visible part of the web page.

required

To make certain fields required (the visitor must fill them in before FormMail will accept the input data), add an input field named "required" to your form, and set its value to a list of field names, separated by commas. For example,

        <input type="hidden" name="required" value="email,realname">

missing_fields_redirect

Normally, if some input fields are required (see previous) but have not been filled in by the visitor, FormMail will generate a simple error page. To redirect the visitor to a separate custom error page, instead of generating the default error page, add an input field named "missing_fields_redirect" to your form, and set its value to the full URL of your error page. For example,

        <input type="hidden" name="missing_fields_redirect" value="http://www.domain.net/missing_fields.html">

Customizing the E-mail

There are several input fields which FormMail recognizes and can use to customize the e-mail message. These config fields are optional. Most of these will usually be hidden input fields, so that they are not a visible part of the web page. However, "subject", "email", and "realname" are more useful as normal input fields.

subject

To specify the subject of the e-mail message, add an input field named "subject" to your form. For example,

        <input type="hidden" name="subject" value="Website Feedback">

To allow a visitor to specify or change the e-mail subject, remove the type="hidden" parameter.

email

To allow a visitor to specify their own e-mail address, add an input field named "email" to your form. FormMail will automatically use any address entered into this input for the From and Reply-to addresses in the e-mail message.

realname

To allow a visitor to specify their own real name, add an input field named "realname" to your form. FormMail will automatically include anything entered into this input in the From address of the e-mail message.

print_config

Normally, FormMail does not include config input fields in the body of the e-mail message, either because they already appear in the e-mail headers (subject, email, realname), or because they are not really relevant. If you want to force some of these fields to be included, add an input field named "print_config" to your form, and set its value to a list of field names, separated by commas. For example,

        <input type="hidden" name="print_config" value="email,realname">

print_blank_fields

Normally, FormMail does not include blank input fields (fields which were not filled out by the visitor) in the body of the e-mail message. If you want to force these to be included, add an input field named "print_blank_fields" to your form, and set its value to "1".

sort

Normally, FormMail prints input data in the body of the e-mail message in the same order as it was submitted by the web browser (which is usually, but not necessarily, in the same order as the input fields in the web form). If you want to sort the fields alphabetically by name, add an input field named "sort" to your form, and set its value to "alphabetic".

You can also specify the field order exactly, by setting the value of the sort field to the phrase "order:", followed by a list of field names, separated by commas. For example,

        <input type="hidden" name="sort" value="order:realname,email,address,city,state,zip,phone">

env_report

Some general information about the server and visitor is stored in environment variables. For example, REMOTE_HOST contains the hostname of the visitor's computer, REMOTE_ADDR contains the IP address, and HTTP_USER_AGENT contains the name of the web browser they are using.

If you want to include some of this information in the e-mail message, add an input field named "env_report" to your form, and set its value to a list of environment variable names, separated by commas.

Customizing the Success Page

Normally, FormMail generates a simple success page for the visitor after sending an e-mail message. There are several input fields which it recognizes and can use to customize or replace the success page. These config fields are optional. Usually, they will be hidden input fields, so that they are not a visible part of the web page.

redirect

To redirect the visitor to a separate custom success page, instead of generating the default success page, add an input field named "redirect" to your form, and set its value to the full URL of your success page. For example,

        <input type="hidden" name="redirect" value="http://www.domain.net/thankyou.html">

title

To specify the title of the default success page, add an input field named "title" to your form, and set its value to the text you want.

return_link_url

To specify a return link back to your web site on the default sucess page, add an input field named "return_link_url" to your form, and set its value to the full URL of your web site. For example,

        <input type="hidden" name="return_link_url" value="http://www.domain.net/">

return_link_title

To specify a return link back to your web site on the default sucess page, add an input field named "return_link_title" to your form, and set its value to the link text you want. For example,

        <input type="hidden" name="return_link_title" value="Return to our Web Site">

background

To specify a background image for the default sucess page, add an input field named "background" to your form, and set its value to the full URL of your background image.

bgcolor

To specify a background color for the default sucess page, add an input field named "bgcolor" to your form, and set its value to the hexcode color (for example, white = #FFFFFF) you want.

text_color

To specify the text color for the default sucess page, add an input field named "text_color" to your form, and set its value to the hexcode color (for example, black = #000000) you want.

link_color

To specify the link color for the default sucess page, add an input field named "link_color" to your form, and set its value to the hexcode color (for example, blue = #0000CC) you want.

vlink_color

To specify the visited link color for the default sucess page, add an input field named "vlink_color" to your form, and set its value to the hexcode color (for example, purple = #551A8B) you want.

alink_color

To specify the active link color for the default sucess page, add an input field named "alink_color" to your form, and set its value to the hexcode color (for example, red = #FF0000) you want.