cgiemail is a CGI to E-Mail gateway. It accepts the results of a form, and
uses a template file to build and construct an
e-mail message containing those results.
To use cgiemail, you must first construct a form for site visitors to use to
send you information. The opening tag of the form must be:
<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/template.txt">
By default, cgiemail will search your htdocs folder for the template.txt file. You can specify a sub-directory of the htdocs folder by using:<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/sub-directory/template.txt">
(this would cause cgiemail to search for template.txt inside the htdocs/sub-directory/ folder)
While you are testing your form, you should substitute cgiecho for
cgiemail in the FORM tag. This will simply print the
mail to your browser's screen, instead of actually sending anything.
The template file that you create must be a plain ASCII text file
(do not upload it in binary mode), and must have the extension
.txt. The template file goes in your Web directory along with
other Web files.
The template file starts with mail headers, which must be followed by a
blank line before the body of the message being sent. If you do not follow
this convention, your mail will be corrupted or will not reach you. The
two most important headers are To: and Subject:, so
always put those first. Here is a sample template file:
To: somebody@somehost.com
Subject: questions three
What is your name? [yourname]
What is your quest? [quest]
What is your favourite colour? [colour]
The variables used in your form - like, <INPUT TYPE=TEXT NAME="last_name"> - are referenced with brackets inside template.txt (ie: [last_name] for this specific example).
The HTML that uses this template would resemble:
<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/template.txt">
Your name: <INPUT NAME="yourname">
<BR>
Your quest: <INPUT NAME="quest">
<BR>
Your favourite colour: <INPUT NAME="colour">
<P>
<INPUT TYPE="submit" value="Send E-Mail">
</FORM>
After the mail has been delivered, the visitor will see a simple
"Success!" page, and nothing more. To add an optional comment to
this result page, add this field to your HTML file:
<INPUT TYPE="hidden" NAME="addendum" VALUE="your message here">
Or better yet, include this field to generate a redirect to a page of your
own design:
<INPUT TYPE="hidden" NAME="success" VALUE="your URL here">
To require that a particular field of the form be filled out, change its
name to have a leading required- in both the HTML file and the
template.
You can include environment variables in the e-mail by putting them in the
template file as field names, with a leading $ sign. For example:
User's browser was: [$HTTP_USER_AGENT]