cgiemail, available on all pair Networks' Web hosting accounts, accepts the results of a form and uses a template file to construct and send an e-mail message containing those results.
To use cgiemail, you must first construct an online form, which allows your Web site's visitors to send you information. If you have a domain name, the opening tag of the online form must be:
<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/template.txt">The "cgi-sys" portion of the ACTION above directs the server to look into the server's cgi-bin so the cgiemail script doesn't need to reside in your individual account.
If you do not have a domain name, or if you are using SSL and do not have your own secure certificate, you must use:
<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/username/template.txt">In either case, cgiemail will automatically find your Web directory and look there (or in a subdirectory you specify) for the template file that you'll need to create.
The template file that you create must be a plain ASCII text file (do not upload it in binary mode through FTP ), and must have the extension .txt. The template file goes in your Web directory along with your other Web files.
The template file starts with e-mail headers, which must be followed by a blank line before the body of the message being sent. If you do not follow this convention, your e-mail will be corrupted or will not reach you. The three most important headers are To:, From:, and Subject:. These headers should always be added first. Here is a sample template file:
To: firstname.lastname@example.orgIn the line with "To:," replace "email@example.com" with the e-mail address that you wish to have the message sent to. In the line with "From:," replace "firstname.lastname@example.org" with the e-mail address that you wish to have the message sent from. In the line "Subject:," replace "CGIEmail Test" with your desired e-mail subject. In the line with "Reply-To:," replace "email@example.com" with the e-mail address that you wish to appear in the "To:" field if the recipient of the e-mail replies to the e-mail.
Subject: CGIEmail Test
Visitor Name : [realname]
E-Mail Address : [required-email]
Visitor Message : [required-message]
Visitor IP : [$REMOTE_HOST]
The HTML that uses this template file would resemble:
<FORM METHOD="POST" ACTION="/cgi-sys/cgiemail/template.txt">After the e-mail has been delivered, the visitor will see a simple "Success!" page and nothing more. To add an optional comment to this result page, add this field to your HTML file:
Visitor Name: <INPUT NAME="realname">
E-Mail Address: <INPUT NAME="required-email">
Visitor Message: <INPUT NAME="required-message">
Visitor IP: <INPUT NAME="$REMOTE_HOST">
<INPUT TYPE="submit" value="Send E-Mail"> </FORM>
<INPUT TYPE="hidden" NAME="addendum" VALUE="Your message has been successfully sent. Thank you for your feedback!">You can also include the following field to generate a redirect to a particular Web site:
<INPUT TYPE="hidden" NAME="success" VALUE="http://example.com/">To require that a particular field of the form be filled out, change its name to have a leading required- in both the HTML file and the template.
You can include environment variables in the e-mail by putting them in the template file as field names with a leading $ sign. For example:
Vistor IP: [$REMOTE_HOST]
While you are testing your form, you should substitute cgiecho for cgiemail in the FORM tag listed above. This tag will simply print the e-mail message to your Web browser's screen instead of sending the e-mail to the e-mail address you specified.
To view an example of cgiemail in action, click here. When viewing the page, right-click your mouse and "View Page Source" for the notes and HTML source code.