Contents
Cal Poly Pomona

CPP FormMail Documentation

Basic use

To make use of CPP FormMail, you need to write an HTML form that refers to the script. The only thing that's required to make it work is to set the action of the script. In HTML, enter <form method="post" action="http://www.csupomona.edu/cgi-group/webteam/cgi-bin/cppformmail.pl">. In Dreamweaver, create a form and put http://www.csupomona.edu/cgi-group/webteam/cgi-bin/cppformmail.pl in the "Action" box:

Action: http://www.csupomona.edu/cgi-group/iit/cgi-bin/cppformmail.pl

The contents of the form will be sent to the email address associated with the user or group where the form is located: A form in http://www.csupomona.edu/~jcclark/ would go to jcclark@csupomona.edu and a form in http://www.csupomona.edu/~biology/ would go to biology@csupomona.edu.

Customization

It is possible to customize the behavior of CPP FormMail by including information in "hidden fields" on the web form. Here's an example which will always send mail to the address "webteam@csupomona.edu" when someone submits the form:

<form method="post" action="http://www.csupomona.edu/cgi-group/webteam/cgi-bin/cppformmail.pl">
  <input type="hidden" name="recipient" value="webteam@csupomona.edu">
  <input type="text" id="text" name="feedback"><br>
  <label for="text">Please enter your comments</label><br>
  <input type="submit">
</form>

Creating a hidden field in Dreamweaver is also easy, using Insert/Form/Hidden Field, or clicking the hidden field button in the Forms toolbar. The field above would look like this:

value: webteam@csupomona.edu

See how the hidden "recipient" input in the example above told formmail who to send the mail to? This is how almost all of formmail's configuration works. The table below contains the full list of things you can set with hidden form inputs. You can create these hidden fields either directly in the HTML or by using the form design tools in a program such as Dreamweaver.

recipient The email address to which the form submission should be sent. If you would like it copied to more than one recipient then you can separate up to two email addresses with commas, for example: <input type="hidden" name="recipient" value="you@csupomona.edu,me@csupomona.edu"> If you leave the "recipient" field out of the form, CPP formmail will send to the email address associated with the user or group that contains the form. This allows you to avoid putting your email address in the form, which might be desirable if you're concerned about address harvesters collecting it and sending you spam.
subject The subject line for the email. For example: <input type="hidden" name="subject" value="From the feedback form">
redirect If this value is present it should be a URL, and the user will be redirected there after a successful form submission. For example: <input type="hidden" name="redirect" value="http://www.csupomona.edu/~webteam/foo.html"> If you don't specify a redirect URL then instead of redirecting, CPP formmail will generate a success page telling the user that their submission was successful.
stylesheet The fully-qualified URL (for example, http://www.csupomona.edu/~webteam/css/form.css) of the stylesheet to be used for the success page that is sent if no redirect page (above) is specified. If you do not wish to use a stylesheet, you may use the six parameters below to control its appearance.
The following attributes remain for compatibility with older forms. If you use a stylesheet (above), you shouldn't use these; they interact in predictable but often unexpected ways.
 bgcolor The background color for the success page.
 background The URL of the background image for the success page.
 text_color The text color for the success page.
 link_color The link color for the success page.
 vlink_color The visited link color for the success page.
 alink_color The active link color for the success page.
title The title for the success page. If you don't specify a title, the success page will default to "Thank You".
return_link_url The target URL for a link at the end of the success page. This is normally used to provide a link from the success page back to your main page or back to the page with the form on. For example: <input type="hidden" name="return_link_url" value="/~webteam/index.html">. If you leave off either this or the next one, there will be no return link.
return_link_title The label for the return link. For example: <input type="hidden" name="return_link_title" value="Back to my home page">. Both this and the parameter above are required to generate a return link.
sort This sets the order in which the submitted form inputs will appear in the email and on the success page. It can be the string "alphabetic" for alphabetic order, or the string "order:" followed by a comma separated list of the input names, for example: <input type="hidden" name="sort" value="order:name,email,age,comments"> If "order:" is used you must supply the names of all of the fields that you want to be in the body of the mail message – if you leave out a field, it won't be included.
csv If the value is set to "true", "yes", or "csv", this appends to the bottom of the email message the contents of all the fields in a comma-separated list, in the sort order specified above. You can copy this, paste it into an Excel spreadsheet, and convert text to columns to keep track of your responses. An explicit sort order (not just "alphabetic") is required for "csv" to work.
print_config This is mainly used for debugging, and if set it causes formmail to include a dump of the specified configuration settings in the email. For example: <input type="hidden" name="print_config" value="title,sort"> ... will include whatever values you set for "title" and "sort" (if any) in the email.
required This is a list of fields that the user must fill in before they submit the form. If they leave any of these fields blank then they will receive an error page telling what was left out and giving them the option of being sent back to the form to try again. For example: <input type="hidden" name="required" value="name,comments">
missing_fields_redirect If this is set, it must be a URL, and the user will be redirected there if any of the fields listed in 'required' are left blank. The user will not be notified of which fields are blank, but you will have more control over the appearance.
env_report This is a list of the CGI environment variables that should be included in the email. This is useful for recording things like the IP address of the user in the email. It is especially useful if you want to use the same form on multiple pages, so that each email will include the page it came from. To do this, include <input type="hidden" name="env_report" value="HTTP_REFERER">. (This is the method that is used on eHelp.)
print_blank_fields If this is set, then fields that the user left blank will be included in the email. Normally, blank fields are suppressed to save space.

As well as all these hidden inputs, there are a couple of non-hidden inputs which get special treatment:

email If one of the things you're asking the user to fill in is their email address and you call that input "email", formmail will use it as the address part of the sender's email address in the email. Even if you don't ask the user for an email address, you might want to set this in a hidden field to your own address or some other actual address, so that it won't default to nobody@csupomona.edu, which is often caught by spam filters.
realname If one of the things you're asking the user to fill in is their full name and you call that input 'realname', formmail will use it as the name part of the sender's email address in the email.

This page is based on the nms FormMail documentation.

Return to CPP FormMail page