This guide will help you write a WWW form that sends an
email message to you using a program called cgiemail. The following steps are
required.
- Create an email template.
- Create the HTML form.
- Make sure the ACTION is correct.
- Upload the necessary cgi's.
- Try out your form with cgiecho.
- Go live with cgiemail.
- Try the cgiemail Control Panel tool.
Here are some nifty options for the advanced user:
Before you start receiving email messages through a web form, you should decide what
these messages should look like. Create an ASCII/text file, called an email template,
that looks something like this:
To: webhelp@earthlink.net
From: mymailform@earthlink.net
Subject: Form Response
Your name: [yourname]
Your email address: [youremail]
Your favorite color: [color]
|
We will call this file results.txt in our example. In one sense, this
template is free-form. People who want to send you e-mail can download this template, fill
it out, and mail it to you. However, the template will be used by the cgiemail
program in this case, so be careful to follow these guidelines:
- Wherever you want the user of your form to supply information, use a single word inside
square brackets with no spaces; for example,
Your name: [yourname]. Not
[Put your name here.].
- In our example
results.txt, the first three lines are the header. For security reasons, do not include any variables (bracketed words) in any of header items,
which should consist of nothing other than the following items:
- Make sure the e-mail address in the To: field is correct. This is the e-mail address
where you want the users to send the form submissions.
- Make sure the e-mail address in the From: field is correct. This is the e-mail address
that you want the email to be from. You may wish to use this address to filter incoming
emails that originated from your form. For security reasons, do not use a variable name for the "From:" header.
- Remove any blank lines before or among the header lines.
- Make sure there is one blank line between the header and the body.
- If you created the file on a Mac, be sure to upload it as text. (Unix computers have
different codes denoting the end of a line than Mac's do, so your file might look like one
long line to the Unix computer if you do not upload it as a text file.)
Now upload your email template to your web hosting account somewhere in the
"www/" directory and look at it with your web browser to check that it was
uploaded.
You do not need to locate your template file in your "cgi-bin/" directory!
Here is an example:
This is the HTML source:
<FORM method="post"
ACTION="/cgi-bin/cgiecho/webhelp/features/cgiemail/emailresults.txt">
Your name: <input NAME="yourname"><br>
Your email address: <input NAME="youremail"><br>
Your favorite color: <input NAME="color"><p>
<input type="submit" value="Send email">
</FORM>
|
This is a very simple example. For more information about creating forms in HTML, see http://help.mindspring.com/webhelp/features/cgiemail/forms.htm
Note that the NAME of each input corresponds to what you
previously put in the email template. In this example they are yourname, youremail,
and color.
We will first test the form with a program called cgiecho. cgiecho does exactly
the same thing as cgiemail, except it will not send the actual email. When the form works
with cgiecho, we will move on to cgiemail.
In our example, the template file results.txt is located in our
"www/features/emailforms/" directory. Therefore, our action line is:
ACTION="/cgi-bin/cgiecho/features/emailforms/results.txt".
If we were to relocate our results.txt to our "www/" directory, the action
line would be:
ACTION="/cgi-bin/cgiecho/results.txt"
So, if you placed your template file in your "www/" directory, you
would use the following FORM tag:
<FORM method="post" ACTION="/cgi-bin/cgiecho/template file">
Don't forget to replace template file with your template file name!
You already have files called "cgiecho" and "cgiemail" in your
cgi-bin directory - these were installed for you when your account was created. If for
some reason they are not there, please install them using the directions below:
After you uploaded your HTML form to your web hosting account, view it in your web
browser, fill in all the fields, and submit it. You should see what the processed form
looks like. If instead you see an error with a number near 500, your ACTION may be
incorrect. Go back to the previous step. Also, you may have
written or uploaded your template file incorrectly. Go back to step 1.
If some of your inputs don't seem to be showing up in the processed form, make sure
that the inputs have the exact same names in the HTML form as in the ASCII/text template
file. For example, NAME="yourname" in the HTML form and [yourname]
in the email template.
Now change cgiecho to cgiemail in the ACTION of your HTML form.
Try it out. You should receive an email message with the processed form. If not, go back
and make sure you correctly followed the instructions in step
1.
If it works, congratulations!
Here is our example in action:
This is the HTML source:
<FORM method="post"
ACTION="/cgi-bin/cgiemail/features/emailforms/emailresults.txt">
Your name: <input NAME="yourname"><br>
Your email address: <input NAME="required-youremail"><br>
Your favorite color: <input NAME="color"><p>
<input type="submit" value="Send email">
</FORM>
|
For more info on cgiemail look at the official cgiemail home page.
7. Try the cgiemail tool on the MindSpring Control
Panel