Return CGI Library
Return Form Handling
The simplest use of this gadget is as a simple tool to translate the contents of a form into an e-mail message.
(Quick link to summary.)
Here is a simple sample form:
<FORM action="/cgi-bin/mail2" method="post">
<input type="hidden" name="TO" value="email@example.com" />
<input type=hidden name=SUBJECT
value="Demo Form from Page1 of /cgi-bin/mail2 docs" />
Who are you? <input type="text" name="realname" /> <br />
e-mail address: <input type="text" name="FROM" /> <br />
Feedback: <textarea name="feedback" cols="50" rows="10" />
</textarea> <br />
<input type="submit" value="Tell us" />
Here is a link to an implementation of it.
In our sample we've left the hidden fields as text fields so that you can easily try it with your own values. (We've also used the
mandatory fields value which is described in a later example.)
OK. Let's explain it line by line.
The first line starts the form and points the submit button at the /cgi-bin/mail2 gadget.
The second line defines a e-mail address to send the results of the form to.
The third line defines a subject for the e-mail message.
The fourth line starts the 'normal' contents of the form. This is just part of the body of the message that will be sent to you.
The fifth line defines a field called FROM which will be used as the return address for the e-mail message (if set).
The sixth line defines a text area field for convenient entry of a large text message. This is another field that doesn't control the
message -- it simply is part of the message body.
The seventh line defines a submit button with the text label "Tell us".
The eighth (and last) line ends the form.
The output from the gadget is a fairly simple e-mail message, as shown below (note that the fields are in SORTED order :-):
Received: from where.else.com [184.108.40.206] and converted to E-Mail by
Date: Sat, 28 Sep 1996 17:13:41 -0700
Subject: Put a subject here
Enclosed below is the input from your form
SUBJECT: Put a subject here
feedback: This is just a simple demonstration example.
realname: Tom Brown
Summary of key points:
- Any form with a TO field in it will generate an e-mail message.
The TO field defines the address the message should be sent to.
- The FROM field defines the message's return address.
- The SUBJECT field defines the message's Subject: line.
- If you need it, the last Received: header line displays what IP address the message came from.