Old and Unsupported Formmail Script - Web Center
This form processing script has been REPLACED with a script that has spam-prevention features and more! Learn about the new Tectite Form Processing Script.
The web servers have a CGI script ("formmail" script) that is used to email HTML form data to an email address. All other form mail scripts that were in use on the old web server have been replaced by this new formmail script.
The formmail script uses hidden fields in the HTML form to set the recipient of the email message, as a number of other helpful configuration parameters (such as subject line, required fields, and the web page the form user should see after submitting the completed form).
As you review your existing web pages, you may find HTML forms that have a number of hidden fields not mentioned below. The old web server's form mail scripts used those hidden fields for configuration. Those fields can be removed from your HTML forms.
Using the Formmail Script
To use the formmail script, set the "action" attribute of the <form> tag to:
<form name="myform" method="post" action="http://www2.ohlone.edu/cgi-bin/formmail.pl">
And, then, set the hidden <input> tag for "recipient" as discussed below.
Aliases for Email Addresses
To protect email addresses from being harvested by spambots and as an additional measure to ensure no one outside Ohlone College uses the formmail script, aliases are used for each recipient's email address.
If the email address you want to use is not on the list of recipient aliases in the formmail script, you must contact the Web Team to have an alias created for that email address. An alias can be created for one or a group of email addresses.
To check whether you already have an email address alias in the formmail script, contact the Web Team.
Required Form Field: Recipient
Only the "recipient" hidden <input> field is required by the formmail script. Here is an example using an alias for the email address:
<input type="hidden" name="recipient" value="admissions and records" />
If you leave the "recipient" field out of the form, the formmail script will not deliver the message and no error will display.
Helpful Form Fields (optional)
There are two non-hidden text <input> fields that get special treatment by the formmail script:
- email - If one of the things you're asking the user to fill in is their email address and you call that <input> tag "email", formmail will use it as the address part of the sender's email address in the email.
<input type="text" name="email" />
- realname - If one of the things you're asking the user to fill in is their full name and you call that <input> tag "realname", formmail will use it as the name part of the sender's email address in the email.
<input type="text" name="realname" />
Advanced Form Configuration (optional)
In addition to the required "recipient" hidden <input> form field, the following hidden fields can be used to set additional configuration parameters:
- subject - The subject line for the email. For example:
<input type="hidden" name="subject" value="Athletics Comment 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.your.domain/subdir/foo.html" />
- 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 be sent back to the form to try again. For example:
<input type="hidden" name="required" value="name,comments">
- 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="alphabetic">
<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.
- 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.
<input type="hidden" name="print_blank_fields" value="1">
- If you don't specify a "redirect" URL, the formmail script will generate a success page telling the user that their submission was successful. To customize that generated page, you can use these hidden fields in your form (the order you use them does not matter):
- title - The title for the success page.
- 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.
<input type="hidden" name="title" value="Thank you!" />
<input type="hidden" name="bgcolor" value="#ffffff" />
<input type="hidden" name="background" value="http://www.yourdomain.com/images/texture.jpg" />
<input type="hidden" name="text_color" value="#000000" />
<input type="hidden" name="link_color" value="#0000FF" />
<input type="hidden" name="vlink_color" value="#FF00FF" />
<input type="hidden" name="alink_color" value="#CC0000" />
- return_link_url - The target URL for a link at the end of the auto-generated 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. For example:
<input type="hidden" name="return_link_url" value="http://www.yourdomain.com/subdir/" />
- return_link_title - The label for the return link. For example:
<input type="hidden" name="return_link_title" value="Back to my homepage" />
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. Use this if you want finer control over the the error that the user sees if they miss out a field.
- 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, the following will include whatever values you set for "title" and "sort" (if any) in the email:
<input type="hidden" name="print_config" value="title,sort">
- 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. Valid CGI environment variables are: