Sending mail from WWW forms with the phone.net mailmap program

You can use the phone.net mailmap program with WWW forms to deliver data from a form to an electronic mail address, formatted for easy use by either. For interactive forms processing, you should use our consulting services.

Setting up a form on WWW requires two major steps:

  1. Creating the form.
  2. Writing the code that handles form submissions.
While we can only provide help for forms that mail comments to you, this server now has a mechanism that could eliminate the need to write any code, and at the very least lets you avoid having to deal with the intracies of the CGI interface.

If the form is designed for collecting information for human perusal, then mailmap can be used to send mail to that human or to a maildrop set up for the purpose. If processing is required, mailmap outputs a stream of values in a format that can be easily parsed by standard text manipulation tools.

Setting up a config file

Like the phone.net imagemap program, you have to set up a config file to use mailmap. After the config file is set up, you need to write the form that will refer to it.

The config file

The config file specifies who to send mail to, the subject of the mail, and the URL of the HTML page to be displayed after the form is mailed. Name the config file mailmap.conf and place it in either the http configuration directory, or a your home directory.

In mailmap.conf, any line beginning with a # is a comment, and will be ignored.

Any non-blank line should be of the form

mapname : URL maildrop subject
mapname is the name of the map given in the ACTION for the form.

URL may be either a path on your server, of the form /path/to/file without the http://server.name part, or an absolute URL.

maildrop is the address to which to send the mail generated by the form.

An entry with the form

testmap : /user-docs/mailmap.html test Just a test message
causes any form referring to testmap to send mail to the user test with the subject Just a test message.

The form

The FORM tag

Except for cases handled by our mail form generator, you still have to set up the form yourself. Read the documentation on that before going further.

To use mailmap, set up a form with with METHOD="POST" and ACTION="http://www.phone.net/cgi-bin/mailmap/user/map." The first part of the URL - cgi-bin - is where script files live at phone.net. If you are using a different server, you may need to use a different name here. The second part - mailmap - is the name of the imagemap program. This will not change unless you change servers.

If the config file is in your home directory, as this one is, the next part of the URL is your user name on that server, so that mailmap can find the config file. If the config file is in the HTTPD config directory, use http://www.phone.net/cgi-bin/mailmap/map.", without user.

The rest of the URL is the name of the map to be found in the config file.

The INPUT tags

Each INPUT tag has a NAME associated with it. This is what you or your program uses to differentiate the inputs. In the mail, each NAME is listed as it occurs. The format is a newline, a :, the number of lines of data for this NAME, the NAME still url-encoded, the data, and a blank line.

For example, the HTML tag <INPUT NAME="phone"> which allows the user to enter a single line would result in the mail having an element of the form:

:1 phone
whatever the user typed

Testing the form

After you set the form up, test it by setting the action to ACTION="/cgi-bin/post-query". This returns a list of NAME and VALUE pairs for each INPUT tag that has a value.

Here's a moderately complex form, using the post-query ntest as above. First, the source:


<FORM ACTION="/cgi-bin/post-query" METHOD="POST">
<H3>Godzilla's Pizza -- Internet Delivery Service</H3>

Type in your street address: <INPUT NAME="address"><P>
Type in your phone number: <INPUT NAME="phone"><P>

Which toppings would you like?<P>
<OL>
<LI><INPUT TYPE="checkbox" NAME="pepperoni" VALUE="topping"> Pepper
oni.
<LI><INPUT TYPE="checkbox" NAME="sausage" VALUE="topping"> Sausage.
<LI><INPUT TYPE="checkbox" NAME="anchovies" VALUE="topping"> Anchov
ies.
</OL>

To order your pizza, press this button:
<INPUT TYPE=submit VALUE="Order Pizza">.<P>
</FORM>

And that produces:

Godzilla's Pizza -- Internet Delivery Service

Type in your street address:

Type in your phone number:

Which toppings would you like?

  1. Pepperoni.
  2. Sausage.
  3. Anchovies.
To order your pizza, press this button: .


Changing the action to ACTION=/cgi-bin/mailmap/admin/nullmap


Godzilla's Pizza -- Internet Delivery Service

Type in your street address:

Type in your phone number:

Which toppings would you like?

  1. Pepperoni.
  2. Sausage.
  3. Anchovies.
To order your pizza, press this button: .



Back to the server lease page.

Please send us any comments you may have. If your client does not support forms, send mail to admin@contessa.phone.net