Introduction:
Formmail is a program that will read fields from an html form that you
setup, email the contents of the form to anyone you choose, and present the
visitor with a prewritten html response page. This is ideal for situations
where you want users to be able to visit your web pages, fill out a form,
and have thier comments emailed back to you.
To use formmail, you will need to create two html pages. One will
contain the actual form that the users can fill out, and the other will be
the page that the users see after they "submit" the form.
In order for formmail to
function you must put several "hidden" input tags on your form. These hidden
tags will not be visible to your users, however formmail will be able to
read the values you set in these tags, and act accordingly.
Each time formmail is invoked, it will read any fields that are on your
form, and format the name of the field, and the data that your users
entered, into an email message and send that email to an address that you
specify, There is no problem with sending the email to your own address, you
will simply receive an email that appears as though you sent it to yourself.
NOTE: formmail will send email to any address that you select, but
please keep in mind that formmail will include extra headers in the email
message including the URL of your webpage that uses formmail. This makes
tracing where the email originates from very easy. Thus it would not be a
good idea to setup a webpage intended to deliver email messages to any
person that is not expecting to receive these emails.
Use of the formmail program to send unwanted email, or spam emails can
result in the termination of your service.
Instructions:
For this example, lets assume your username is jdoe and your email
address is jdoe@yhti.net and you want the email to be sent to you.
You would need to create an html document that the user would see after
they submit your form, lets call it formresponse.html, this page can be any
page that you like, but it typically would say thank you for your email and
I will get back to you as soon as possible.
Then for the actual form, create another web page that looks something
like the folowing
You must change the jdoe to your username
You must change yourdomain to your registered domain name
<html>
<head>
<title>My First Email Form</title>
</head>
<body>
<form action="/cgi-bin/formmail.pl" method="post">
<input type="hidden" name="X-sender" value="jdoe@yhti.net">
<input type="hidden" name="X-recipient" value="jdoe@yhti.net">
<input type="hidden" name="X-responsepage"
value="http://www.yourdomain.com/formresponse.html">
<input type="hidden" name="X-debug" value="yes">
Name <input type="text" name="name"><br>
<input type="submit">
</form>
</body>
</html>
This form includes the X-debug tag, which will cause formmail to skip
sending the mail, but present you with a page that will show what the email
would look like if it had been sent. After you have everything the way you
would like, remove the X-debug tag and the time the form is submitted the
email will then sent.
The contents of the name and value portions of each hidden tag are
detailed below
- Required Fields
- Field Name: X-sender
- Purpose: Determines what email address the email will be sent from.
- Example: <input type="hidden" name="X-sender" value="you@yourdomain.com">
- Comment: Do not set this to an email address that does not
belong to you.
- Field Name: X-recipient
- Purpose: Determines where the email message will be sent.
- Example: <input type="hidden" name="X-recipient" value="you@yourdomain.com">
- Field Name: X-responsepage
- Purpose: Determines what web page users will be taken to after they click on the submit button.
- Example: <input type="hidden" name="X-responsepage" value="http://www.yourdomain.com/formresponse.html">
- Optional Fields
- Field Name: X-subject
- Purpose: Determines what the subject line of the email message will be.
- Example: <input type="hidden" name="X-subject" value="My Form Email">
- Comment: If this tag is missing, the email will be sent with the subject line "no subject specified on form"
- Field Name: X-debug
- Purpose: Helps you debug your form and see what the email will look like.
- Example: <input type="hidden" name="X-debug" value="yes">
- Comment: If this tag is set to "yes", the email will not be sent, instead you will see a page that lists the control tags, and what the email would look like.