How do I have the contents of an online form emailed to me?
- Step 1: Construct the ACTION
Use the appropriate ACTION in your HTML. Make sure the FORM tag looks like:
<FORM ACTION="/sharecgi/mail.cgi" METHOD="POST">
- Step 2: Decide on an identifier
Decide on a simple identifier for the form. This
identifier should be one word with no spaces. Good
identifiers would be words like signup or
mailinglist. The identifier can only contain the
letters a-z,A-Z and 0-9.
- Step 3: Add the hidden field to your form
In your form, specify a hidden field named 'template',
and set its value to the identifier you chose in step
2. The template is used to specify the confirmation
page, and to design the format of the email. For
example, if you chose the identifer myForm in
step 2, the HTML you would need would look like
<input type="hidden" name="template" value="myForm">
- Step 4: Create the HTML template
Develop the HTML file that you would like to be
displayed after the user hits the 'Submit' button.
Store this file in the wizform subdirectory
of your HTML root directory. The name of this file
should be blah.html, where blah is
the identifier you chose in step 2. For example, if
you chose the identifier myform, the HTML
file name would be myForm.html. If your HTML
root directory does not have a subdirectory named
wizform, then create that directory using
your FTP program, and then store the file there.
- Step 5: Create the mail template file
The mail template file is the file that will be used
to format the email message that's sent out. The file
will be named blah.txt where blah is
identifier you chose in step 2. For example, if you
chose the identifier myform, the mail
template file name would be
The mail template
file can contain any number of d strings that look
like -=this=-. Whatever is between the
-= and the =- will be replaced by
the value of the form field whose name is between the
-= and the =-. For example, if
there is a form field named 'firstname', as in, say,
<input name="firstname">, then if there
is the string "-=firstname=-" in the mail template
file, that string will be replaced by whatever the
user typed in the field named firstname.
The mail template file must include the mail header
and the body of the email. The official description
of the mail format can be found here,
but for our purposes, the following rules are usually
A mail message is composed of a header and body.
The header and body are separated by a blank line.
The header must contain one or more lines of the
the type: 'Name: Value' where 'Name' is the name of
the header, and 'Value' is the value of the header.
Note the ':' and single space between 'Name' and
Each header name and value pair should be on a single line.
The following headers must be present: "From", "Return-Path", "Subject" and "To".
The following example shows a simple "Contact Us"
page, and the associated HTML and template files.
|contact.html HTML template file|
|contact.txt Mail template file|
|From: "-=yourname=-" <-=youremail=->
Return-Path: "-=yourname=-" <-=youremail=->
Subject: New Email from Website
NEW EMAIL FROM WEB SITE
As you may have realized, it's possible to fake email
addresses using invalid From: headers. Not only is
that not nice, it may violate our Acceptable Use
Policy. Please be aware that we will log all emails
so that if any threatening, illegal or
inappropriate mails are sent out using this system, we
can cooperate with the authorities by providing them log file.