Policies: Web Policies and Style Manual - Data Collection Without Writing a CGI

The easiest way to collect data via the web is to have the data mailed to the collector. The mailto form can collect answers to queries and mail them. The data collected will be emailed to someone who can collect it.

If extensive responses are expected or if automated processing is desired for some other reason, we suggest that you use the procmail program to process the mailed form.

To learn about procmail, see man procmailex and man procmailrc. A brief description follows, but the manual pages have the full description.

Procmail has the ability to differentiate messages from one another based on the sender of the message, or the subject, for example.

Email from the web will be from "nobody" and the subject field of the mail message should be set to something identifiable when you design the page. e.g.

<INPUT TYPE=HIDDEN NAME=mailto_subject VALUE="my-mqp-response">

The first thing to do is to set up handling of your incoming mail by the procmail program. To do that, put this exact line in your .forward file:

/usr/local/bin/procmail

After that line is in, all mail that arrives will be handed to the procmail program. The procmail program is controled by the contents of the .procmailrc configuration file in your home directory.

The following .procmailrc file would write any message from "nobody", with a subject line that has "my-mqp" somewhere in the line, into a file "stack-up-nobody". If those checks don't match, any messages with a subject containing "my-mqp" will be written to a file "stack-up-other", and, finally, anything that doesn't match either of those checks will go to your regular mail box (ORiGinal MAIL).

:0
* ^From nobody
* ^Subject:.*my-mqp
stack-up-nobody

:0
* ^Subject:.*my-mqp
stack-up-other

:0
$ORGMAIL

The form is simple; :0 on the first line of each rule, some lines of checking starting with *, and a place to put the mail. A blank line deliniates the end of a rule. On the rule lines, the ^ means "beginning of line", so procmail won't get confused by "Subject" appearing somewhere within a line, but only at the beginning.

If you want procmail to run a program of yours to process the mail, the | character will introduce the program:

SHELL=/bin/sh

:0
* ^From nobody
* ^Subject:.*my-mqp
|/home/your-login/MQP/Process

Any mail processing program should be carefully written to be able to handle messages which the mailto will be sending.

webmaster@wpi.edu
Last modified: Thursday, 15-May-2003 11:32:57 EDT
Maintained by webmaster@wpi.edu
Last modified: May 15, 2003, 11:32 EDT
[WPI] [Home] [Back] [Top]