CGIemail

CGIemail is a script that allows you to send the contents of a form to an email address. While it can make the results look a little bit nicer than Formmail, it is considerably more difficult to set up than Formmail.

You can learn more about CGIemail by visiting their user guide. If you have any questions or comments about CGIemail, please consult their guide.

To begin you will need to create a template. A template might look like:

From: [email]
To: email@yourdomain.com 
Subject: questions three

What is your name?              [yourname]
What is your favorite color?  [color]

Now upload this template to your site. You should upload it into your public_html directory. While you can name the template anything, you will need to note the name of the template. For this example, I named my template template.txt. There are a couple of things to note. First, notice the double space after the Subject line. This is used to symbolize the end of the email headers, this is required. Second, note the words inside the brackets ([]'s). These will be used later when you construct the form.

NOTE: Do not use space when you are naming your form options, denoted by the words inside the brackets ([]'s).

Now you will need to create a form. To go along with the template I created earlier, my form looks like:

<FORM NAME="Inquiry" ACTION="/cgi-sys/cgiemail/template.txt" METHOD="POST">
Your Email Address: <INPUT TYPE="textbox" NAME="email"><br>
Your Name: <INPUT TYPE="textbox" NAME="yourname"><br>
Favorite Colour: <INPUT TYPE="textbox" NAME="color"><br>
<INPUT TYPE="Submit">
</FORM>

There are a couple things that need to be noted here as well. First note the NAME parameters. Each INPUT TYPE will have a NAME parameter. This will correspond directly to the words you entered in the templates in the brackets. For example, the line:
Your Name: <INPUT TYPE="textbox" NAME="yourname"><br>
will refer to:
What is your name?              [yourname]
in the template.

Instead of the system emailing you:
What is your name?              [yourname]
it will send you:
What is your name?              The user's name
Also, note the first tag in the FORM:
<FORM NAME="Inquiry" ACTION="/cgi-sys/cgiemail/template.txt" METHOD="POST">
You can Name the form anything, but the ACTION parameter must be set as above. With the exception that template.txt becomes whatever you named your template at the start. The system will then send email to the To: portion of the template, and the email will look just as it does in the template.

Advanced cgiemail

You can use cgiemail to hide your e-mail address and to send the form to multiple addresses. For example, consider the template.txt file:


From: [email]
To: email@yourdomain.com
Cc: another@address.com
Subject: questions four

What is your name?              [yourname]
What is your favorite color?  [color]

Notice how I have included a Cc: another@address.com. This means that the form will be sent to both address, email@yourdomain.com and another@address.com

Now upload the template.txt file into your public_html directory on your account. When you have it uploaded, change the permissions on the file to 600, or so that the user column has read and write permissions and everything else is turned off. A lot of FTP clients allow you to change the permissions of a file. Changing the permissions of the template.txt file means that outside users will not be able to view your template by going to http://yourdomain.com/template.txt.

Now create the form that uses this template:

<FORM NAME="Inquiry" ACTION="/cgi-sys/cgiemail/template.txt" METHOD="POST">
Your Email Address: <INPUT TYPE="textbox" NAME="email"><br>
Your Name: <INPUT TYPE="textbox" NAME="yourname"><br>
Favorite Colour: <INPUT TYPE="textbox" NAME="color"><br>
<INPUT TYPE="hidden" NAME="success" VALUE="http://yourdomain.com/success.html">
<INPUT TYPE="Submit">
</FORM>

Notice that I have added a new hidden input type named success. This tells cgiemail the page to send users when they successfully complete the form. Now just upload this form onto your website and try it out.