Web Based E-mail Forms


You can create a web page on your web site to allow visitors to send you e-mail messages. With an e-mail form, you can allow users to register for conferences, send feedback, or answer an on-line poll. With additional tools supplied by the Math Department, you can import these messages into a spreadsheet or database.

Creating an E-mail Form

To create an e-mail form, simply use a text editor to create a web page in your space on the Math Department web server. The process will not work from outside the department. Create a form on the page with the action attribute of the form tag set to https://www.math.wisc.edu/formMail/formMail.php. You can have any number of fields on the form however certain fields have special meaning. The following form fields are required:



The following fields are optional:



Complete example:

<FORM action="https://www.math.wisc.edu/formMail/formMail.php" method="POST">
<INPUT name="recipient" type="hidden" value="jheim@math.wisc.edu">
 <INPUT name="subject" type="hidden" value="Computing Feedback">
  <INPUT name="env_report" type="hidden" value="REMOTE_ADDR,HTTP_USER_AGENT">
Your email:  
<INPUT name="email" type="text">
<BR>

Your name:
  <INPUT name="realname" type="text">
  <BR>

  Your comments:
  <TEXTAREA name="comments"> </TEXTAREA>
  <BR>

  <INPUT type="submit" value="Submit">

  </FORM>

This example gives the following feedback form:

Your email:
Your name:
Your comments:



Configuring procmail

You may wish to configure your mail so that all messages from an on-line form are delivered to a particular mailbox. To do this, you must edit your procmail configuration file. Procmail is a standard unix/linux tool that many mail systems, including that of the UW Math Department, use to filter mail. You can change the rules procmail uses to filter your mail by logging on to login.math.wisc.edu, and editing the file /auto/mail/<your-user-id>/.procmailrc. For example, if your user ID is 'bogus', you'd edit the file /auto/mail/bogus/.procmailrc. This file will already contain several procmail "recipies". A typical procmail recipie for filtering mail based on the subject of an email message would look like this:
:0:
* ^Subject: Online form: Computing Feedback
.feedback/
Nore information on using procmail can be found on the , Using Procmail page.

You can also automatically create a rule that filters messages into a mailbox via the newrule script. To use this program take the following steps.
  1. Create a new mail folder with your email program of choice.
  2. Send yourself a test message with your on-line form. Transfer the test message into your new mail folder.
  3. Log onto login.math.wisc.edu and run the newrule program. You must pass the newrule program the name of your mail folder. For example if your new folder is named 'feedback', you would type this:
    newrule feedback
    

The newrule program will examine the subject line of the message in the folder and automatically create a procmail rule to transfer any additional incoming messages with the same subject into the folder.

Manipulating the Messages

Once you have created an e-mail folder containing the messages from your web form, you can import them into a database or spreadsheet via the mbox2csv program.

  1. log onto login.math.wisc.edu
  2. Run the mbox2csv command redirecting the output to a file. For example, if you have saved all the messages from your form in a mail folder named feedback, you could create a file named feedback.csv by typing the following:
     mbox2csv feedback > feedback.csv
     
    This file can then be imported by many database and spreadsheet programs. For example, if you use Windows, double-clicking on the file will launch Microsoft Excell and open the file.

    By default, mbox2csv tries to discover the data fields in your messages and displays them in alphabetical order in the CSV output. You can change this behavior by supplying a comment separated list of fields when you run mbox2csv. For example, the following command will display just the realname, email, and comments fields.
     mbox2csv feedback realname,email,comments
     

If you encounter a problem with the information on this page, please contact staff@math.wisc.edu.