cgiemail is simular in funtionality to the simple formmail script, but it also allows you to control the format of the email message that is sent. This is done by providing the script with a text template that will be used to format the email message.
Using the cgiemail Script
Step 1: Create an email template.
This is a text file that cgiemail uses to format the results of the feedback form before it emails it. This template must contain an email header, so it might be easiest to take sample template file and leave the email header in place. Upload this file in ASCII mode to the directory of your choice. Be sure your FTP software is using ASCII mode or the script will not work. If you get a "server error" when submitting your form, it is quite likely that you didn't upload in ASCII mode.
The email template file is very flexible, but uses a fairly simple concept. Each variable surrounded by
[ ] in the template will be looked for in your form. If it is there, the value that is input for that variable on your form will be replaced in the template file.
Step 2: Create your confirmation page.
This is an HTML document that will be displayed after the user submits the form. You can put anything you want on this page, it just depends on what you want the user to see after they submit the form.
Step 3: Create your form.
It might be easier to copy the HTML from this example and modify it.
Step 4: Update your form tag.
<form> tag so that it posts to cgiemail as follows:
<form method=POST action="/cgi-bin/cgiemail/template-path-and-filename">
The template-path-and-filename is the path and filename of your email template file.
Step 5: Add the required fields, required-to, success, and subject.
These fields can be configured as predefined hidden fields, or input from the user. To create them as predefined hidden files create them as follows:
<INPUT TYPE=HIDDEN VALUE="firstname.lastname@example.org" name="required-to">
<INPUT TYPE=HIDDEN VALUE="http://your.domain/your-confirmation-page.html" name="success">
<INPUT TYPE=HIDDEN VALUE="your-subject" name="subject">
Replace the following with the values of your choice:
email@example.com - This is the email address you want the results of the form sent to.
your-confirmation-page.html - This is the path and filename of the HTML document that you want displayed after the form is processed.
your-subject - This is what will appear as the subject line of the email message.
Note: If you want to make any field on your form a required entry, proceed the variable name with
ActionWeb's implementation of cgiemail has been completely rewritten, but is compatible with an early public domain version that was developed by MIT.