Formmail.pl
Introduction
Form-mail provides a mechanism by which users of a World-
Wide Web browser may submit comments to the webmasters (or anyone else) at a site. It should be compatible with
any CGI-compatible HTTP server. It provides a facility
to order the output and to redirect form submissions to
a chosen page (for example, a "Thank You" page or the site's
main index.)
[ top ]
Using Formmail
Formmail is an external file called by a form when, for example,
the Submit button is clicked. Its output is controlled by parameters
that are set using form fields.
The parameters that can be set are:
recipient
- The email address of the person to whom the
results from the form are to be sent. This email address must be registered with
us by phoning 0118 9773763. This field is mandatory.
redirect
- The page to display once the form has been sent. This page should be on the local site and given in the form "/filename"
subject
- The subject of the email which the form will send.
sort
- The order to display the form results in the email, as
a comma separated list beginning "order:".
- These parameters are set using hidden input fields of the form:
<input type="hidden" name="parameter" value="value">
- These fields are not displayed on the screen, nor will they be included in the email unless specifically requested.
- The whole form will therefore look something like:
<form name="FormName" action="location of formmail.pl"
method="post">
<input type="hidden" name="recipient" value="email@address">
<input type="hidden" name="redirect" value="/filename">
<input type="hidden" name="subject" value="Subject of Email">
<input type="hidden" name="sort" value="order:FieldName1,FieldName2,...">
...<input type="..." name="FieldName..." value="...">...
</form>
See the Example for more details.
[ top ]
Example
I wish to allow visitors to my web site to send me feedback.
I want to know their email address, their web site address (if they have one),
and, of course, their comments. When they send me feedback, I also want
to thank them.
Here is the initial form:
(Note that the form doesn't currently do anything.)
- And here is its HTML source:
<form name="Feedback Form">
Email Address: <input type="text"
name="Email"><p>
Your comments: <textarea name="Comments"></textarea><p>
Your website address: <input type="text"
name="URL"><p>
<input type="submit" value="Submit"
name="Submit"><p>
</form>
Suppose that formmail.pl is in a directory called cgi-bin. In order to call it, my form
tag needs an 'action' and a 'method':
<form name="Feedback Form" action="/cgi-bin/formmail.pl"
method="post">
My email address is ben@yourdomain.com. I must include a hidden input field containing this information, like so:
<input type="hidden" name="recipient" value="ben@yourdomain.com">
My "Thank You" page is just an ordinary HTML page, called "thank.htm" in my root directory. To redirect to this page, I need to add the following field to my form:
<input type="hidden" name="redirect" value="thank.htm">
I want the subject of the email the form sends me to be "Web Site Comments"
(without the quotes) so that I know what it's about. I set the subject with this field:
<input type="hidden" name="subject" value="Web Site
Comments">
Finally, I want to see the browser's Email address first, then their comments and finally the web page address. I can do this using 'sort',
using a comma separated list and starting the field with "order:" as follows:
<input type="hidden" name="sort" value="order:Email,Comments,URL">
- Here is the final HTML source for the form:
<form name="Feedback Form" action="/cgi-bin/formmail.pl"
method="post">
<input type="hidden" name="recipient" value="ben@yourdomain.com">
<input type="hidden" name="redirect" value="thank.htm">
<input type="hidden" name="subject" value="Web Site Comments">
<input type="hidden" name="sort" value="order:Email,Comments,URL">
Email Address: <input type="text"
name="Email"><p>
Your comments: <textarea name="Comments"></textarea><p>
Your website address: <input type="text"
name="URL"><p>
<input type="submit" value="Submit"
name="Submit"><p>
</form>
- The full form looks lke this:
Compare it to the one above: there is no visual difference. However,
clicking the "Submit" button now will
send an email to ben@yourdomain.com and redirect your browser to a new page.
[ top ]
Credits
Form-mail.pl
Created 94 by Reuven M. Lerner (reuven@the-tech.mit.edu).
Updated 96 by Tim Howling
Updated 00 by Ben Williams
Form-mail is free software, redistributed and modified under the terms
of the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version.
Note that this