Difference between revisions of "CGI Email"
m (CGI Email moved to Hosting Archive:CGI Email) |
|
(No difference)
|
Revision as of 16:54, 7 March 2008
Contents
Introduction
For easy reference and comparison, XMission creates a simple email form in your public_html directory when your account is activated. The files are mail.html (the fill-out form) and mail.txt (the template message). You may choose to modify these to fit your needs or just view their structures to better understand how you will need to create your own.
For more details about CGI Email, or to learn how to set it up on your own server, refer to MIT's CGI Email help pages.
Creating the Form
When you create your form, there are two main things you will need to do. The first is to be certain that all the form fields have a unique name. The second is to properly set the <form> tag. Any standard form entries may be used (such as radio buttons, check boxes, pull-down select menus, etc.). Below is a short example of a proper form, but you may also review your mail.html.
<html> <head> <title>John Doe's Email Form</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <p>Please fill out the form below.</p> <hr> <form method="POST" action="http://www.xmission.com/cgi-bin/cgiemail/~username/mail.txt"> Your Name: <input type="text" name="name" size="50"><br> E-Mail Address: <input type="text" name="required-email" size="50"><br> Subject: <input type="text" name="subject" size="50"><Br> <Br> Message / Request: <Br> <textarea name="content" rows=10 cols=66></textarea> <Br> <input type="submit" value="Send" name="submit"> <input type="reset" value="Clear" name="reset"> </form> </body> </html>
<form method="POST" action="http://www.xmission.com/cgi-bin/cgiemail/~web/contact/order.txt">
A notable bonus of using cgi-email is shown above in green. You can make a field required by preceding its name with "required-". XMission recommends that you make the email address a required field. The reason being, if you reply to your form and there is no email address present, your reply will automatically be sent to XMission's webmaster instead of the intended recipient.
Creating the Template Message
The template message is the email message that will be sent to you when the form is submitted. It's a simple text file in the format of an email message. Because cgi-email sends this text file as an email message, it must have the proper header fields to work properly and must not have any blank lines before the first field.
The format of the template after the header lines is up to you. The only thing you must have is the names of the form fields in brackets. Below is an example of a text template to go with the form above. You may also review your mail.txt file.
To: John Doe <username@xmission.com> From: name <required-email> Reply-to: required-email Subject: subject Sender's Name: name Email Address: required-email Comments or Request: content
You would, of course, replace "John Doe" with the name of the person or department that the email message is being sent to, and "username@xmission.com" with the destination email address.
Adding a "success" Page
By default, there is a text confirmation page that notifies the sender that the email message was sent successfully. However, some XMission subscribers would like to replace it with a nicer HTML success page. This is easy with cgi-email.
You will need to open the HTML form and add a hidden form field. The syntax will look like the following example
<input type="hidden" name="success" value="http://www.xmission.com/~acctname/successpage.html">
Unlike the other form fields, you cannot change the name of the "success" field. It must be named "success" for it to work properly. The value is the URL of the success page that you want to appear after the sender has successfully completed and submitted the form. The example above will show the file named "successpage.html" in acctname's public_html directory. The success page value must be a fully-qualified URL, so you may want to be sure it works in a browser first.