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:
- recipient This field is used
to specify the recipient of the e-mail message. normally,
this would be your e-mail address. The address must be a
valid Math Department e-mail address. You cannot use this
service to send e-mail to
addresses outside the Math Department. You can have the
message sent to more than one address by listing
the addresses seperated by a comma. Example:
<INPUT name="recipient" type="hidden" value="jheim@math.wisc.edu">
- subject The message subject. You will
probably want to set this to something distinctive so
that you can filter your mail based on the subject. Example:
<INPUT name="subject" type="hidden" value="Conference registration">
- email This field is the sender's e-mail address.
The message will appear to have come from this address. Example:
<INPUT name="email" type="text">
The following fields are optional:
- realname This field is used to allow the user
to enter his real name. Example:
<INPUT name="realname" type="text">
- required This field allows you to specify that
certain fields are filled out when the form is
submitted. If a visitor to your site clicks the submit
button without filling out a field, an error message is
displayed and he is asked to return
to the form to fill out the field. Example:
<INPUT name="required" type="hidden" value="realname">
- sort This field is used to allow for a custom sort
order of the form fields. The
syntax is each field name separated by commas. If you omit
a field name in the list, but it's a valid form field, the
field will NOT be shown in the email.
- env_report This field is used to specify that
you wish to receive additional environment settings to be
included in the form results. Valid values are REMOTE_USER,
REMOTE_ADDR, and HTTP_USER_AGENT. These values should be
separated by commas.
- REMOTE_USER: If the user is in an authenticated zone of your site, this would
be the username they are logged in with.
- REMOTE_ADDR: This is the IP address of the users computer.
- HTTP_USER_AGENT: This is the user agent field as set by the users browser, which
typically has the browser type in it.
Example:
<INPUT name="env_report" type="hidden" value="REMOTE_ADDR,HTTP_USER_AGENT">
- redirect This field is used to specify which URL
you wish to be displayed to the user upon a successful form
submition. This can be a relative or absolute pat. There is
a default Thank You page built in.
- errror_redirect This field is used to specify
which URL you wish to be displayed to the user upon
encountering an error. This does not include missing fields,
but rather just errors with field data and errors pertaining
to submitting the form. This can be a relative or absolute
path . there is a default Error page built in.
- missing_fields_redirect This field is used to
specify what URL you wish to be displayed to the user upon
encountering a missing field. This can be a relative or absolute
path . there is a default missing field Error page built in.
>
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:
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.
- Create a new mail folder with your email program
of choice.
- Send yourself a test message with your on-line form.
Transfer the test message into your new mail folder.
- 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.
- log onto login.math.wisc.edu
- 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.