skip navigation

This page looks better in modern browsers. Please upgrade.

Brown Home Brown Home Brown Home Brown CS

mailform CGI Command

Purpose

The mailform gateway provides a general-purpose way to retrieve form data as email messages.

Syntax

Href
/cgi-bin/mailform
Method
POST or GET
Required Parameters
mail_to
A comma-separated list of destination email addresses.
All destination addresses must end with @cs.brown.edu.
Optional Parameters
required
A comma-separated list of cgi parameters which are required to process this form.
mail_from
A single email address to appear on the "From" line in the mail header.
mail_cc
A comma-separated list of email addresses to which the results should be sent as a "carbon-copy."
mail_subject
Text to appear on the "Subject" line in the mail header.
mail_begin
A string to appear in the body of the mail message just before the form data begins. A newline is appended so that the string appears on a line by itself.
mail_end
A string to appear in the body of the mail message just after the form data ends. A newline is appended so that the string appears on a line by itself.
mail_prefix
A string which is prepended to each line of the body of the mail message on which form input data (as opposed to the field names) appears. This makes it easier to automatically parse the mail messages.
report
A comma-separated list of cgi parameters which should be reported via both the web and email.
report_web
A comma-separated list of cgi parameters which should be reported via the web. This overrides "report".
report_mail
A comma-separated list of cgi parameters which should be reported via email. This overrides "report".
debug
If set, no email is produced. If the value is "email", then the text of the email message is returned via the web.
success_page
The file name of a .html file in the web which will be used as a template for all successful responses.
error_page
The file name of a .html file in the web which will be used as a template for all error responses. If there is an error involving the use of this page, a default error page is used instead.

Template Pages

The parameters success_page and error_page can be used to customize the response page of a form without the need to do any cgi programming. Mailform reads in the template page and performs simple text-replacement on certain special strings. The result is sent to the form-submitter as the response.

The text which is replaced in the template takes the form of HTML comments. Each is of the form

	<!--string-->
where "string" is the name of the replacement text.

success_page Text Replacement

<!--base-->
The base path of the replacement page. Use this as the value of the base attribute of the <body> tag in the template to enable the use of relative file references within the page.
<!--results-->
A simple text list of the form input, as it would appear by default in email. This should normally be formatted within a <pre>...</pre> container.
<!--param-->
The value of each cgi parameter generated by the form is available as replacement text. So, for instance, the value supplied for parameter Choice1 is used to replace <!--Choice1--> wherever it appears in the template.

error_page Text Replacement

<!--base-->
The base path of the replacement page. Use this as the value of the base attribute of the <body> tag in the template to enable the use of relative file references within the page.
<!--error-->
The text of the error message.

Examples

A Simple Form

Normally, you would make the mail_to parameter hidden, so that all submissions go to the same predetermined address, but in this example you can type in your email address, so that you can see both the default web reply and email forwarding of the input data.

<form	method=POST action="/cgi-bin/mailform">
Email:
<input	type=text name="mail_to" size=50 value="login@cs.brown.edu">
<br>
<select name="choose" size=1>
        <option>foo
        <option>bar
        <option>baz
</select>
<br>
<textarea       name="tarea" cols=60 rows=3>
This is some
multi-line text.
</textarea>
<br>
<input	type=submit>
</form>
Email:


A Fancier Form

In this example, we use the html template feature of mailform. Also, this form does not generate email - instead use the selection input item to choose between the normal web response and what you would have received in email. This makes use of the debug parameter, for debugging forms. Here's the form:

<form	method=POST action="/cgi-bin/mailform">
<input	type=hidden name="mail_to" value="never@cs.brown.edu">
<input	type=hidden name="success_page"
	value="/system/software/web/cgi/mailform_reply.html">
<input	type=text name="random" size=60
	value="Here's some random text">
<br>
Select the response type:
<select name="debug" size=1>
        <option>web
        <option>mail
</select>
<br>
<textarea       name="tarea" cols=60 rows=3>
This is some
multi-line text.
</textarea>
<br>
<input	type=submit>
</form>

And here's the template:

<html>
<head>
<title>Example Form Response Template</title>
</head>
<body	bgcolor=#ffffcc>
<h1>Example Form Response Template</h1>
For the first text field, you entered:
<font color=red><!--random--></font>
<p>
The text area at the end contained:
<font color=red><!--tarea--></font>
</body>
</html>

Finally, the form itself:


Select the response type:


Page Owner: Kathy Kirman Last Modified: Wed Jun 11 10:51:18 2003