Click here to visit our Sponsor

Server CGI Support for cgiemail


We have pre-installed Bruce Lewis' cgiemail program (this link has excellent additional documentation) for use with your HTML FORM's. This program will accept the output of any HTML FORM using the POST method, and email the results to a specified email address using a configurable email template so that you may format the contents of the email.


Installing cgiemail

To install cgiemail you will need to log into your console.   Once there you will see a list of options, select Install prewritten scripts.   You will then see a list of prewritten scripts, select whether you want to install or overwrite the version you currently have in your cgi-bin.  The screen will look like this:

install overwrite script name script description
cgiemail This is a web-to-email gateway.

Select which you would like to do and click submit.  If done correctly you will receive a message saying the script was installed successfully.   If you do not receive this message then the script was not installed.


USING CGI-EMAIL

There are two different methods of invoking this program from your forms, one for virtual accounts, and one for secure server access.

For Virtual-Domain Accounts:

<FORM ACTION="/cgi-bin/cgiemail/mailtemp.txt" METHOD=POST>

The above code will call the cgiemail script, which will in turn reference the template file "mailtemp.txt", which defines the format by which the submitted form contents will be sent via email. Here is an example mailtemp.txt.

For the above examples, the template file "mailtemp.txt", should be in your /cgi-bin directory. Here is an example form.

Templates can be created in a basic text editor and uploaded to the server in ASCII format. A basic template consists of the following:

The first two lines must contain:

   To: username@yourdomain.com
   Subject: Output of my form

Remember to substitute the desired recipient email address and subject above.

Next, you will need to add ALL field names within the HTML form to the template. Each field name used in your HTML FORM should be contained within brackets ("[ ]") within the template. For example, if you had the following three fields in your HTML form:

   <input name="name" type="text">
   <input name="address" type="text">
   <input name="phone" type="text">

Your Template might look like the following:

   To: username@yourdomain.com
   Subject: Output of my form

   Name            [name]
   Address         [address]
   Telephone #     [phone]

It is recommended that you use all lowercase field names within your HTML form and template. Be sure to upload the template in ASCII transfer mode.

If you want a specific web page to load when the email is successfully sent, such as a thank you note, add the follow code to your HTML form:

<input type="hidden" name="success" value="http://your_domain.com/thanks.shtml">

Substitute the URL of the file you wish to load after form data is submitted. The field name in this case MUST be "success", but does not need to be added to the template.

USING THE SECURE SERVER:
The same conditions apply when using the secure server, you just have to change the call to:
https://secure.megaton.net/<domain_name>/cgi-bin/cgiemail/mailtemp.txt

You should send a request to help@megaton.net to activate the secure server for your domain name if you have not already done so.

Important Note For use with the Secure Server
When using a custom response in conjunction with a secure form, the "thank you" page URL must also be accessed through the secure server. For example:

<input type="hidden" name="success" value="https://secure.megaton.net/<domain_name>/thanks.html">


Tips and Tricks

Email you receive from your forms will have a return address associated with webstor.com. If you would like to directly "reply&quote to the person that submitted the form using your email software, you may do the following:

First, add a field to the HTML form (e.g. "email" to prompt the user for their complete email address.

Next, add the field name to the corresponding template in the following manner:

   To: username@yourdomain.com
   From: [email]
   Subject: Output of my form

The cgiemail script will insert the address entered in the field named email, and the email you receive will appear to have been sent directly from this person thus allowing you to use your email program's "reply" feature to directly write to this person.


For More Information

cgiemail is a very popular and widely used program, a wealth of information can be found at the cgiemail home page at:


If you have problems setting up this program, please send email to help@megaton.net with the following info:

  1. Your account name (or domain name)
  2. The page in your account that contains the broken form.


Back to the Index