User Documentation


All you need is your html form, a format file and (optionally) a response file.


  1. Your html form must have two hidden input fields, named ‘destination’ and ‘subject’. The ‘destination’ field will have the email address where the email is to be sent, and the ‘subject’ field will contain the subject for the email message.
  2. Other message headers can be set using inputs of the form header: For example, to set the Reply-To: header, use the html .
  3. The format file is essentially the body of the email message to be sent. Form fields that you want in the email message just need to have a ‘$’ pre-pended to them. i.e. a form field of ‘name’ will become ‘$name’ in the format file.
  4. The ACTION attribute of the FORM tag should be set to http://your-local-host/cgi-bin/, and the METHOD should be POST.
  5. The format file must be in the same directory as the HTML form, and with the same name as the form, but with an extension of ‘.data’ instead of ‘.html’. e.g. If your form is ‘myform.html’, then your format file must be called ‘’. If your form is called ‘myform.htm’, make sure you read the note below.
  6. The response file must be in the same directory as the HTML form, and with the same name as the form, but with an extension of ‘.response’ instead of ‘.html’ (as with ‘.data’ above). The response file will contain the html page you be returned to the user upon successful completion of the form. It can also contain the same fields as the format file (i.e. use $name to display fields that the user filled out).
  7. If you wish to make the filling out of some fields in your form mandatory, you can add a “required” file. Create a file called ‘myform.required’, containing one or more lines of field-nameDescription. Each field name will be checked against the input to see if it isn’t empty. If it is, an error will be shown using the Description to instruct the user to fill in that particular field.
  8. If you don’t wish to send an email message, and only want to format and show the response file, include an input field of the name nodata set to the value true.
    In this situation, you don’t need a format (.data) file, just a response file.
  9. If you want to use an index file for your form (i.e. where the URL of the page ends in ‘/’), you will need to include a hidden field which specifies the name of the index file:
    You can replace “index.html” with the appropriate filename.
  10. You might also like to add a hidden field that contains the absolute URL of the form. This will assist users whose browsers or proxy servers don’t send or remove the Referer header (which CGI-Mailer relies upon). This field must be called CgiMailerReferer.
    You can replace “” with the appropriate URL.
  11. You can reproduce CGI environment variables in the email message and response page by simply referring to them directly. e.g. $ENV{'REMOTE_HOST'}
  12. [Note: users with inferior and/or broken operating systems that only allow 8.3 filenames must use .htm, .dat, .res & .req extensions for the respective files.]


Example HTML form: Format file:

<H1>Enter some values:</H1>

<FORM METHOD="POST" ACTION="http://your-local-host/cgi-bin/">
<INPUT TYPE="HIDDEN" NAME="destination" VALUE="" />

<INPUT TYPE="HIDDEN" NAME="subject" VALUE="testing cgi-mailer" />
<INPUT TYPE="TEXT" NAME="one" SIZE="10" />

<INPUT TYPE="TEXT" NAME="two" SIZE="10" />
<INPUT TYPE="TEXT" NAME="three" SIZE="10" /><BR />

<INPUT TYPE="TEXT" NAME="four" SIZE="10" />
<INPUT TYPE="TEXT" NAME="five" SIZE="10" />

<INPUT TYPE="TEXT" NAME="six" SIZE="10" /><BR />
<SELECT NAME="list"><BR />



First Value: $one
Third Value: $three
Fourth: $four; Second: $two

Fifth: $five; Sixth: $six
List option: $list

Filled-out HTML form: Email sent:

Enter some values:

Subject: testing cgi-mailer

First Value: The
Third Value: Brown

Fourth: Fox; Second: Quick
Fifth: Jumped; Sixth: Over
List option: Green

Note: Be sure that the field names in the “.data” and “.response” files are exactly the same as those in the “.html” file.

Leave a Reply

You must be logged in to post a comment.