Difference between revisions of "CGI Email"
(→Introduction) |
|||
(One intermediate revision by one other user not shown) | |||
Line 18: | Line 18: | ||
<p>Please fill out the form below.</p> | <p>Please fill out the form below.</p> | ||
<hr> | <hr> | ||
− | <form method="POST" action="http:// | + | <form method="POST" action="http://user.xmission.com/cgi-bin/cgiemail/~username/mail.txt"> |
Your Name: <input type="text" name="name" size="50"><br> | Your Name: <input type="text" name="name" size="50"><br> | ||
E-Mail Address: <input type="text" name="required-email" size="50"><br> | E-Mail Address: <input type="text" name="required-email" size="50"><br> | ||
Line 34: | Line 34: | ||
− | In red, you will see the <form> tag. The method will be post, and the action will be your template message through our cgi-email script. The syntax shown in the form tag above should be followed exactly. You will, of course, replace "acctname" with your XMission account name, and mail.txt with the location and name of your template message. Your template message must be located in your public_html directory or a sub-directory within it. To show an example of a variation, the XMission username will be "web", the template message will be located in the public_html/contact/ directory, and it will be named "order.txt". <pre><form method="POST" action="http:// | + | In red, you will see the <form> tag. The method will be post, and the action will be your template message through our cgi-email script. The syntax shown in the form tag above should be followed exactly. You will, of course, replace "acctname" with your XMission account name, and mail.txt with the location and name of your template message. Your template message must be located in your public_html directory or a sub-directory within it. To show an example of a variation, the XMission username will be "web", the template message will be located in the public_html/contact/ directory, and it will be named "order.txt". <pre><form method="POST" action="http://user.xmission.com/cgi-bin/cgiemail/~web/contact/order.txt"></pre> |
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. | 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. | ||
Line 72: | Line 72: | ||
{{footer}} | {{footer}} | ||
[[Category:Hosting Archives|CGI Email]] | [[Category:Hosting Archives|CGI Email]] | ||
+ | tag cgiemail |
Latest revision as of 13:58, 3 December 2012
Contents
Introduction
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://user.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://user.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. tag cgiemail