The utility "feedback.cgi" will send your form to the e-mail gateway. There is
only one required form input tag (recipient) 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 "feedback.cgi" on your
site. By default, form fields are sorted as they appear in the form.
Return to top
Step 1.
The CGI Configuration File -
* We need your help setting these values *
Please send an e-mail request to
ebsunix@dis.wa.gov to be added to the server configuration with a list
recipients for "@allow_mail_to" and any "%recipient_alias" you would like.
-
$max_recipients is set to "3".
You may send a form to no more than three e-mail
recipients.
"$max_recipients "- The maximum number of e-mail addresses that any single form
should be allowed to send copies of the e-mail to. If none of your forms
send e-mail to more than one recipient, then we recommend that you improve the
security of "feedback.cgi" by reducing this value to 1. Setting this
variable to 0 removes all limits on the number of recipients of each e-mail.
-
We need all the e-mail recipients
you will be sending all of your forms to so we can configure this field.
"@allow_mail_to" - A list of the e-mail addresses that "feedback.cgi" can send
e-mail to. The elements of this list can be either simple e-mail addresses
(like 'you@your.domain') or domain names (like 'your.domain'). If it's a domain
name then *any* address at the domain will be allowed.
Example: to allow mail to be sent to 'you@your.domain'
or any address at the host 'mail.your.domain', you
would set:
@allow_mail_to = qw(you@your.domain mail.your.domain);
-
You may, optionally, use alias recipient name(s)
To do so, just send us each alias and its value(s).
"%recipient_alias" - A hash for predefining a list of recipients in the script,
and then choosing between them using the recipient form field, while keeping
all the e-mail addresses out of the HTML so that they don't get collected by
address harvesters and sent junk e-mail.
For example, suppose you have three forms on your site, and you want each to
submit to a different e-mail address and you want to keep the addresses hidden.
You might set up %recipient_alias like this:
%recipient_alias = (
'1' = > 'one@your.domain',
'2' = > 'two@your.domain',
'3' = > 'three@your.domain',
);
To set up multiple recipients (up to three) for a single alias, try this:
%recipient_alias = ( 'animals' = >
'zebra@zoo.domain,cat@home.domain');
In the HTML form that should submit to the recipient 'two@your.domain', you
would then set the recipient with:
<input type="hidden" name="recipient" value="2" />
Return to top
Step 2. Form Design
EXAMPLE 1: A simple feedback form
You now need to write an HTML form that refers to the "feedback.cgi" script.
Here's an example which will send mail to the address 'feedback@your.domain'
when someone submits the form:
<html>
<head>
<title>What is your favorite plant ?</title>
</head>
<body>
<form method="post" action="http://your.domain/cgi-bin/feedback.cgi">
<input type="hidden" name="recipient" value="feedback@your.domain"
/>
<input type="text" name="feedback" /><br />
<table>
<tr>
<td>What is your favorite plant?</td>
<td><input type="text" name="plant"
/></td>
</tr>
</table>
<input type="submit" />
</form>
</body>
</html>
Return to top
Form Configuration
See how the hidden 'recipient' input in the example above told "feedback.cgi"
who to send the mail to? This is how almost all of feedback.cgi's configuration
works. Here's the full list of things you can set with hidden form inputs:
recipient (required) - The e-mail address to which the form submission should be
sent. If you would like it copied to more than one recipient then you can
separate multiple e-mail addresses with commas, for example:
<input type="hidden" name="recipient"
value="you@your.domain,me@your.domain" />
subject - The subject line for the e-mail. For example:
<input type="hidden" name="subject"
value="From the feedback form" />
redirect - If this value is present it should be a URL, and the user will be
redirected there after a successful form submission. For example:
<input type="hidden" name="redirect"
value="http://www.your.domain/foo.html" />
If you don't specify a redirect URL then instead of redirecting "feedback.cgi"
will generate a success page telling the user that their submission was
successful.
bgcolor - The background color for the success page.
background <- The URL of the background image for the success page.
text_color - The text color for the success page.
link_color - The link color for the success page.
vlink_color - The vlink color for the success page.
alink_color - The alink color for the success page.
title - The title for the success page.
return_link_url - The target URL for a link at the end of the success page. This
is normally used to provide a link from the success page back to your main page
or back to the page with the form on. For example:
<input type="hidden" name="return_link_url"
value="/home.html" />
return_link_title - The label for the return link. For example:
<input type="hidden" name="return_link_title"
value="Back to my home page" />
sort - This sets the order in which the submitted form inputs will appear in the
e-mail and on the success page. It can be the string 'alphabetic' for
alphabetic order, or the string "order:" followed by a comma separated list of
the input names, for example:
<input type="hidden" name="sort"
value="order:name,e-mail,age,comments">
If "order:" is used you must supply the names of all of the fields that you want
to be in the body of the mail message.
required - This is a list of fields that the user must fill in before they
submit the form. If they leave any of these fields blank then they will be sent
back to the form to try again. For example:
<input type="hidden" name="required"
value="name,comments">
missing_fields_redirect - If this is set, it must be a URL, and the user will be
redirected there if any of the fields listed in 'required' are left blank. Use
this if you want finer control over the the error that the user see's if they
miss out a field.
print_blank_fields - If this is set then fields that the user left blank will be
included in the e-mail. Normally, blank fields are suppressed to save
space.
Return to top
EXAMPLE 2: Setting the e-mail Subject
This example extends example 1 by adding a customized e-mail subject line:
<input type="hidden" name="subject" value="Favorite Animal" />
With this line added, the HTML now looks like:
<form method="post" action="http://your.domain/cgi-bin/feedback.cgi">
<input type="hidden" name="subject" value="Favorite Animal" />
<input type="hidden" name="recipient" value="feedback@your.domain"
/>
<input type="text" name="feedback" /><br />
<table>
<tr>
<td>What is your favorite animal?</td>
<td><input type="text" name="animal"
/></td>
</tr>
</table>
<input type="submit" />
</form>
Since the subject is set in the HTML form rather than in the script itself, you
can have many different forms on your site, each using a different subject for
the e-mail.
Return to top
EXAMPLE 3: Copies to multiple recipients
This example extends example 2 by sending a copy of the e-mail to each of two
different addresses. For this example, I'll assume that you want the mail
sent to both zebra@zoo.domain and cat@home.domain.
There are two different ways to do this, and I'm going to show the most secure
way. This approach keeps the e-mail addresses out of the HTML, which is
desirable because it's common practice for the senders of junk e-mail (SPAM) to
collect target e-mail addresses from Web sites.
# USER CONFIGURATION SECTION
# --------------------------
# We will modify these settings for you. Please send an e-mail request
to ebsunix@dis.wa.gov.
%recipient_alias = ('animals' = >
'zebra@zoo.domain,cat@home.domain');
The HTML form uses a hidden "recipient" input with a value of "animals":
<form method="post" action="http://your.domain/cgi-bin/feedback.cgi">
<input type="hidden" name="subject" value="Favorite Animal" />
<input type="hidden" name="recipient" value="animals" />
<input type="text" name="feedback" /><br />
<table>
<tr>
<td>What is your pet's name ?</td>
<td><input type="text" name="pet name"
/></td>
</tr>
</table>
<input type="submit" />
</form>
Return to top
EXAMPLE 4: Multiple forms with different recipients
This example adds an additional form to the same site, this time asking people
about their favorite plant. The results of this form get mailed to a new
address, <foo@your.domain>.
We will configure the %recipient_alias to tell "feedback.cgi" how to handle a
recipient value of "plants":
%recipient_alias = (
'animals' = >
'your-name@your.domain,your-name@somewhere-else.domain',
'plants' = > 'foo@your.domain',
);
The HTML form for the plants page will look like this:
<head>
<title>What is your favorite plant ?</title>
</head>
<body>
<form method="post" action="/cgi-bin/feedback.cgi">
<input type="hidden" name="subject" value="Favorite Plant" />
<input type="hidden" name="recipient" value="plants" />
<table>
<tr>
<td>What is your favorite plant ?</td>
<td><input type="text" name="plant name"
/></td>
</tr>
</table>
</form>
</body>
</html>
Return to top
EXAMPLE 5: You want to be able to Reply to the e-mails
Suppose you have the setup in example 4 working, and you decide that you want to
ask the visitors to the Favorite Plant page for their e-mail address in the
form, and have "feedback.cgi" use the address that they enter as the 'From'
address for the e-mail, so that you can hit 'reply' in your mail software to
mail the visitor and strike up a conversation about their favorite plant.
"feedback.cgi" will do this automatically so long as the input where the visitor
sets their e-mail address is given the name "e-mail". If the input where
the visitor gives their name is called "realname" then "feedback.cgi" will use
this as the comment part of the e-mail address.
No change is needed to "feedback.cgi" for this example, we just add an "e-mail"
field to the form and rename the "name" input to "realname":
<head>
<title>What is your favorite plant ?</title>
<link rel="stylesheet" type="text/css" href="/css/nms.css" />
</head>
<body>
<form method="post" action="/cgi-bin/feedback.cgi">
<input type="hidden" name="subject" value="Favorite Plant" />
<input type="hidden" name="recipient" value="plants" />
<table>
<tr>
<td>What is your name ?</td>
<td><input type="text" name="realname"
/></td>
</tr>
<tr>
<td>What is your e-mail address ?</td>
<td><input type="text" name="email"
/></td>
</tr>
<tr>
<td>What is your favorite plant ?</td>
<td><input type="text" name="plant"
/></td>
</tr>
<tr>
<td colspan="2"><input type="submit"
/></td>
</tr>
</table>
</form>
</body>
</html>
Return to top
Confirmation Message
The confirmation message will always be:
From: you@your.com
Subject: form submission
Thank you for your form submission.
Return to top