CGI Email Tutorial
This tutorial will teach
you how to use the CGIEmail script that is pre-installed with your
hosting accout.
What is CGIEmail?
CGIEmail is a form mailing script, similar in function to Matt Wright's
formmail.pl, but it uses a text based email template instead of just sending
an email with a list of form variables.
Where is CGIEmail
located?
http://www.yourdomain.com/cgi-sys/cgiemail
Save the html form. For this
tutorial, we will save it as form.html.
Notice we chose the name of the
email template to be myform.txt. You can name it
whatever you wish (note: do not name it email.txt! it won't work). The path
of the form action="" should be /cgi-sys/cgiemail plus
the path to your email template file. In this case, our email template file,
myform.txt, is located in the same place as our html form. But if it were
located in say a subfolder named foobar, then the form action=""
would look like this:
The Email template is just a
regular plan text file. You can name it pretty much whatever you want,
except "email.txt" . The first couple of lines must include the
following information:
From:
To:
Subject:
To use the data submitted in
the form, place the form field name inside []. We will name our template myform.txt
for the purpose of this tutorial. So our email template will look like this:
From: [emailaddress]
To: you@yourdomain.com
Subject: Website Form data
Hi, my name is [firstname] [lastname]
My email address is [emailaddress]
Now save the myform.txt
andform.html.
3.) Testing our Form
Now that we have our html page,
and our email template, we just need to upload it to our website and test
it. When you submit a form, you should see a page that shows the email that
will be sent to the recipient.
4.)
Extra CGIEmail Features
Here are some extra features
that cgiemail supports:
Required Form Fields
Prepend required- to the name of the form field in
both your html form, and the email template and it will force the user to
enter a value for that field. Your code should look something like this:
form.html:
<INPUT TYPE="text" NAME="required-firstname">
myform.txt
Hi, my name is [required-firstname]
Submission Success Page
You can have the user directed to a html page
of your choice after they submit the form, instead of being taken to a page
showing the email. To do this, put the following code in your html form page.