Form Mail Script
The Form Mail CGI script is a simple script that send the contents
of a form via E-mail. To use the script, you will need to create
a webpage with the appropriate input fields and hidden options.
When a use of this web page enters in data and clicks submit, an
email message is created and sent out.
Download the sample HTML file
The first step is to download and save locally the sample
Form mail HTML file. You can use this as a base for your Form
mail web page or as a guide on how to modify your existing Form
mail web page.
Fields
The Form mail script relies on visible and hidden HTML form tags
to get the necessary information to send its email. The following
table provides a list of the Folly the link on the tag name for
a detailed description of the tag and it's usage. Only the recipient
tag is required, however, we recommend you at least include the
realname and email tags. Any tags not listed below but included
in the form will be e-mailed to you in the body of the message.
The following tags are used by form mail:
| Tag Name |
Type |
What it does |
| recipient |
hidden |
REQUIRED. Email address of where to send the email that the
form mail CGI generates. If this tag does not exist, a message
will not be created and the user will see an error message. |
| email |
visible |
REQUIRED. Return email address. |
| subject |
visible |
Message subject |
| realname |
visible |
User's real name |
| name |
visible |
Same as realname |
| redirect |
hidden |
If this field in included in the form, the user will be redirected
to this URL instead of seeing the default response page. |
| required |
hidden |
List of the required fields in the form. |
| env_report |
hidden |
List of environment variables to include in the email message. |
| sort |
hidden |
Sort order of variables that appear in the email message. |
| print_config |
hidden |
List of variables to include in the email message. |
| title |
hidden |
Title of the resultant web page. |
| return_link_url |
hidden |
Return Home link URL for resultant web page |
| return_link_title |
hidden |
Text to display in the return_url_link |
| The remaining tags affect the appearance of the
resultant web page. |
| background |
hidden |
Background GIF image |
| bgcolor |
hidden |
Background color |
| text_color |
hidden |
Color of the page's text |
| link_color |
hidden |
Color for the links on the page |
| vlink_color |
hidden |
Color for the links that have been visited. |
| alink_color |
hidden |
Color for the link when the have been activated (clicked on) |
Form mail tag details
recipient
REQUIRED. If this field does not exist, no email will be generated,
and the user will receive an error. This field is generally a hidden
field and specifies the email address for the destination of the
email message generated by the form.
Syntax: <input type="hidden" name="recipient"
value="user@domain.com">
[ Top ]
email
REQUIRED. This tag is generally a visible field that allows the
use to specify a return email address. This will be put into the
From: field of the message you receive. You should also include
this field in the list of required fields with the required tag,
otherwise, a CGI error message will be generated.
Syntax: <input type=text name="email">
[ Top ]
subject
The subject field will allow you to specify the subject that you
wish to appear in the email after completion of the form. If this
tag is not used, then the form mail CGI will default to a message
subject: WWW Form Submission.
Syntax:
If you wish to choose what the subject is: <input type=hidden
name="subject" value="Subject">
To allow the user to choose a subject: <input type=text name="subject">
[ Top ]
realname / name
The realname and name tags are interchangeable. This is for compatibility
with older form mail forms. The realname and name fields permit
the user to enter their real name. It becomes part of the From:
line in the email message.
Syntax: <input type=text name="realname"> or <input
type=text name="name">
[ Top ]
redirect
When the form mail form completes, then by default it returns a
confirmation web page to the user. If you wish to not use the default
conformation webpage, you can redirect them to your own confirmation
page or other web page by specifying the URL for this page in the
redirect tag. Optionally, you can make this a visible tag and let
the user specify what web page to go to.
Syntax: To choose the URL they will end up at: <input
type=hidden name="redirect" value="http://www....">
To allow them to specify a URL they wish to travel to once the
form is filled out: <input type=text name="redirect">
required
Some fields in your form can be made to be mandatory. The required
tag permits you to force the user to complete a set of "required"
fields. If the user fails to do so, that he/she will get an error
message asking them to go back and complete the missing field.
To use the 'Required' tag, place all tag names that you want to
be mandatory into this tag.
Syntax: If you want to require that the user fill in the email
and phone fields in your form, use a syntax like: <input
type=hidden name="required" value="email,phone">
[ Top ]
env_report
This tag allows you to have environment variables included in the
email message you receive. This can be useful if you wish to know
what browser they were using, what domain they were coming, from
or any other attributes associated with environment variables. This
following table is a short list of valid environment variables that
you may find useful:
| REMOTE_HOST |
Sends the hostname from which the user originates. |
| REMOTE_ADDR |
Sends the IP address of the remote host making the request. |
| REMOTE_USER |
If the server supports authentication and the script is protected,
this is the username they have authenticated as. This is
usually not set. |
| HTTP_USER_AGENT |
The browser that the client is using to send the request. |
For a full list of environment variables available, please refer
to the Zeus
Documentation.
Syntax: If you wanted to find the remote host and browser sending
the request, you would put the following into your form: <input
type=hidden name="env_report" value="REMOTE_HOST,
HTTP_USER_AGENT">
[ Top ]
sort
This tag allows you to choose the order in which you wish for your
tags to appear in the email that Form mail generates. You can choose
to have the field sorted alphabetically or you can specify a set
order in which you want the fields to appear in your mail message.
By leaving this field out, the order will simply default to the
order in which the browsers send the information to the script which
may or may not be the same order they appeared in the HTML form.
When sorting by a set order of fields, you should include the phrase
"order:" as the first part of your value for the sort
fields, and then follow that with the tag names you want to be listed
in the email message, separated by commas.
Syntax: To sort alphabetically: <input type=hidden name="sort"
value="alphabetic">
To sort by a set field order: <input type=hidden name="sort"
value="order:name1,name2,...">
[ Top ]
print_config
print_config allows you to specify which of the config tags you
would like to have included in your e-mail message. By default,
no config tags are included in your email. This is because of the
the important for fields, like email, subject, etc... are included
in the header of the message. However, some form mail users like
to have the option to have tags included in the message body that
normally are not. The config tags that you wish to have included
should be in the value attribute of your input tag separated by
commas.
Syntax: If you want to print the email and subject fields in the
body of your message, you would place the following form tag: <input
type=hidden name="print_config" value="email, subject">
[ Top ]
title
This form field allows you to specify the title and header that
will appear on the resulting page if you do not specify a redirect
URL.
Syntax: If you wanted a title of 'Feedback Form Results': <input
type=hidden name="title" value="Feedback Form Results">
[ Top ]
return_link_url
This tag allows you to specify a URL that will appear, as return_link_title,
on the resultant "Email was sent!" report page. This field
will not be used if you have the redirect tag set, but it is useful
if you allow the user to receive the report on the following page,
but want to offer them a way to get back to your main page.
Syntax: <input type=hidden name="return_link_url"
value="http://your.host.xxx/index.html">
[ Top ]
return_link_title
This is the title that will be sued to link the user back tot eh
page you specify with return_link_url. The two fields will be shows
on the resulting form page as:
<ul>
<li><a href="return_link_url">return_link_title</a>
</ul>
Syntax: <input type=hidden name="return_link_title"
value="Back">
[ Top ]
background
This form tag allows you to specify a background image that will
appear if you do not have the redirect field set. This image will
appear as the background for the form results page.
Syntax: <input type=hidden name="background"
value="http://your.host/image.gif">
[ Top ]
bgcolor
This form tag allows you to specify a bgcolor for the form results
page in much the same way you specify a background image. This tag
only takes effect if the redirect tag is not used.
Syntax: For a background color of white: <input type=hidden
name="bgcolor" value="#FFFFFF">
[ Top ]
text_color
This tag works in the same was as bgcolor, except that it will
change the color of your text.
Syntax: For a text color of Black: <input type=hidden
name="text_color" value="#000000">
[ Top ]
link_color
This tag changes the color of links on the resulting page. It works
in the same way as text_color.
Syntax: For a link color of Red: <input type=hidden name="link_color"
value="#FF0000">
[ Top ]
vlink_color
This tag changes the color of visited links on the resulting page.
It works exactly the same as link_color.
Syntax: For a visited link color of Blue: <input type=hidden
name="vlink_color" value="#0000FF">
[ Top ]
alink_color
This tag changes the color of active links on the resulting page.
It works exactly the same as link_color.
Syntax: For an active link color of Green: <input type=hidden
name="alink_color" value="#00FF00">
[ Top ]
|