Form using CGIemail

Article Details
URL: http://www.w3helpdesk.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=28
Article ID: 28
Created On: 13 Apr 2010 3:23 PM

Answer The script "cgiemail" in your cgi-bin allows you to receive information entered into a form by email. This script requires the following two steps: 1. Create a template of the email message to be sent. 2. Create an HTML form that fits the email template The complete documentation about cgiemail can be found at http://web.mit.edu/wwwdev/cgiemail/user.html . Simple Example : The script is relatively simple to use. And the quickest way to begin using is a simple example. Here is an example template and HTML form: Email Template : --------------------------------------------------- To: myemailaddress@somedomain.com From: [email] Subject: Response Form Email [userresponse] --------------------------------------------------- HTML Form : --------------------------------------------------- Example Form

Example Form

Your e-mail address:
Comments:

--------------------------------------------------- The key items to notice are: In the template in part 1 there are two fields with brackets around them. They are [email] and [userresponse]. These are variables within the form that will be replaced with text entered in by the HTML form. In the form there are two form fields. They are named "email" and "userresponse". Notice that they match the variables within the template. The most complex part is getting the FORM ACTION correct. The action must start with "/cgi-bin/cgiemail/". The portion at the end is the name of the file that has the template. So in the example the template was stored in the file name "template.txt". Kindly note that you have to place the template.txt file and the HTML Form in the same directory. If you are NOT placing both the files in the home directory, you have to give the directory name in the Form Action part of the form. So for example, if you are placing both the files in the directory called "FORM", then you have to leave the form action part as: "/cgi-bin/cgiemail/FORM/template.txt".