University of Louisville -- dare to be great

Skip Navigation

Data Center Services
Home Page

Web Documentation

IT Home

Accounts

Services

Policies

Major Initiatives

News

Units

Contact

cgiemail: The Form Mailer


cgiemail is a CGI program created at MIT which simply takes the input from an HTML form, puts it into a preformatted letter, and e-mails it to a specified address. It can be used for all forms which simply elicit information from the user which needs to be e-mailed to the owner of the page: applications, registrations, user feedback, bug reports, product orders, etc. Those interested in simpler applications of cgiemail at UofL should visit the UofL.mail help page.

Here's how it works:

Step 1

Create a web page which has a basic fill-out form on it. For example, say you want a person who comes to your site to be able to send you a message if they find a problem with your web pages. You could make a form which looks like this:
_

Your name:

Your e-mail address:

The problem you found:

That form was created with the following HTML code:


     <form method="post"
           action="/cgi-bin/cgiemail/docs/cgiemail/letter.txt"><br />

       Your name:<br />
       <input type="text" name="name" size="40" /><br />

       Your e-mail address:<br />
       <input type="text" name="email" SIZE="40" /><br />

       The problem you found:<br />
       <textarea name="problem" cols="40" rows="4" /></textarea>

       <input type="submit" value="Send Problem Report" />
       <input type="reset" value="Start Over" />
     </form>

As you can see there are two HTML tags used to tell the Browser how to set up the fields into which information is placed: INPUT and TEXTAREA. Each field is given a unique NAME. This name identifies the field so that cgiemail can know where to put it. You can put as many fields as you want. Notice that the name and e-mail address fields are TYPE="text". There are many other types of input fields, including check boxes, pop-up menus, and pick-lists. You can learn more about the things you can do with forms on the NCSA Fill-Out Forms page.

Step 2

Now you have to tell cgiemail what to do with the information that was put into the fields of your form. You do this by creating a text file which tells cgiemail both how to lay out the letter that it sends and where to send it. Here is a simple letter template, called letter.txt, for the form above:
From: [email]
To: userid@louisville.edu
Subject: Problem with Web Pages

Name of Reporter: [name]
E-Mail Address: [email]
Problem with the page:
[problem]

Notice that the words in square brackets are the same as the names of the fields assigned by the NAME segment of the INPUT and TEXTAREA tags above. cgiemail substitutes the areas surrounded by square brackets with the text that was typed into the corresponding field on the HTML form page. Also notice that the ACTION segment of the FORM tag above calls cgiemail and tells it where to find the letter.txt template file:

     <form method="post"
           action="/cgi-bin/cgiemail/docs/cgiemail/letter.txt">

Notice that the section of the address after "/cgi-bin/cgiemail" is the same as what you would put if it were after "http://www.louisville.edu". Put the template file into the directory with your HTML files and make sure that everyone has read permissions, just like you have to do with your HTML files.


©2006 University of Louisville. All rights reserved.

U of L Home | U of L A to Z | Contact