Shortcuts for Web Team:
- mail_options - Exclude, KeepLines, NoEmpty, more
- Advanced Features
Web forms (HTML forms) allow you to receive information from your site visitors via email. First, learn the basics of creating HTML forms for your website. Then, configure your HTML form to work with the Tectite FormMail form processing script (with built-in spam-prevention!) that is already installed on the main Ohlone College web server. You do not need to install the script in order to use it.
Basics of HTML Forms
A "form processing script" accepts data from an HTML form and sends the data to one or more specified email addresses.
FormMail uses hidden fields in the HTML form to set the recipients of the email message as well as a number of other helpful configuration parameters (such as subject line, required fields, and the web page to be displayed after the user submits the form).
Tell the <form> to use the Tectite FormMail Script
To use the Tectite FormMail script, set the "action" attribute of the <form> tag to:
<form name="myform" method="post" action="http://www2.ohlone.edu/tectitefm/fm.php">
Then, set the hidden <input> tag for "recipients" to the desired email alias as discussed below.
Only the "recipients" hidden <input> field is required by the Tectite FormMail script. Here is an example which uses an alias for the recipient's email address (see information about aliases):
<input type="hidden" name="recipients" value="a_and_r" />
If you leave the "recipients" field out of the form, FormMail will fail with an error of "no valid recipients".
To protect email addresses from being harvested by spambots and as an additional measure to ensure no one outside Ohlone College uses the Tectite FormMail script, obfuscated email addresses (aliases) are used for the "recipients" field. The Web Team maintains a list of aliases for use with the FormMail script.
To check whether you already have an alias for the "recipients" field of your HTML form or to request an alias, contact the Web Team. An alias can be created for one or more email addresses.
If the recipients value you want to use is not on the list of aliases, FormMail will fail with an error of "no valid recipients".
How to Select Multiple "recipients"
The use of the square brackets is required to choose multiple <select> options.
<select name="recipients" multiple="multiple">
<option value="acad_aff">Academic Affairs</option>
<option value="bus_off">Business Office</option>
<option value="coun_dept">Counseling Department</option>
<option value="stu_svcs">Student Services</option>
Converting from the old NMS Formmail Script (formmail.pl)
If you are converting to Tectite FormMail from NMS Formmail, you must change the name of the "recipient" hidden form field to "recipients" and replace all spaces in the value of the "recipients" field to an underscore (_). For example:
<input type="hidden" name="recipient" value="john and mary smith" />
<input type="hidden" name="recipients" value="john_and_mary_smith" />
If you use checkbox fields in your HTML form, the Tectite FormMail script requires the use of empty square brackets at the end of the value of the "name" attribute for the <input type="checkbox"> field. For example (using an ordered list (<ul>) as is appropriate for a list):
<ul> <li><input type="checkbox" name="FavoriteFruit" id="apple" value="Apple" /> <label for="apple">Apple</label></li> <li><input type="checkbox" name="FavoriteFruit" id="banana" value="Banana" /> <label for="banana">Banana</label></li> <li><input type="checkbox" name="FavoriteFruit" id="orange" value="Orange" /> <label for="orange">Orange</label></li> <li><input type="checkbox" name="FavoriteFruit" id="plum" value="Plum" /> <label for="plum">Plum</label></li> </ul>
...which looks like this:
Use CSS to turn off the list bullets:
Important: If you do not use the empty square brackets, Tectite FormMail will record only the value of the last checked checkbox. For example, if the user checked Apple and Orange and Plum, only the value of Plum will be included in the email message.
By the way, if you don't recognize the <label> field, learn about Creating Accessible Forms at WebAIM.
There are two <input> fields that get special treatment by FormMail:
email - If one of the things you're asking the user to fill in is their email address and you set the name attribute of that <input> tag to "email", FormMail will use the value entered by the user in the From: field of the email message generated.
<input type="text" name="email" />
If the field for the user's email address is not named "email", the email field can be derived as follows (see also advanced form fields):
<input type="hidden" name="derive_fields" value="email=Email_Address" />
realname - If one of the things you're asking the user to fill in is their full name and you set the name attribute of that <input> tag to "realname", FormMail will use the value entered by the user in the From: field of the email message generated.
<input type="text" name="realname" />
If you are asking for the user's first name and last name separately, the realname field can be derived as follows (see also advanced form fields):
<input type="hidden" name="derive_fields" value="realname=First_Name+Last_Name" />
The following hidden fields can be used to set additional configuration parameters:
email (see Helpful Form Fields above)
subject - The subject line for the email that is sent to the recipients. For example:
<input type="hidden" name="subject" value="Athletics Comment Form" />
required - A list of fields the user must provide, together with a friendly name. The field list is separated by commas, and you append the friendly name to the field name with a colon (:). For example:
<input type="hidden" name="required"
email: Email Address,
comments: Comments or Questions">
good_url - The URL of the web page to display after the form has been successfully processed by FormMail. For example:
<input type="hidden" name="good_url" value="http://www2.ohlone.edu/your/path/formthanks.html" />
derive_fields - A mechanism for deriving form fields by concatenating other form fields (see Tectite How-to for Deriving Fields from Other Fields).
- + (plus sign) joins fields together with a single space, but only if the following field is not empty
- . (period) joins fields together with no space added between
- * (asterisk) joins fields together and always adds a single space between
Example with multiple derive_fields options set:
<input type="hidden" name="derive_fields" value="realname=firstname+lastname, email=EmailAddress, fullphone=area.phone, address=street*suburb" />
Spaces around the equal sign (=), around the plus sign (+), and after the comma (,) are optional.
mail_options - A list of comma-separted options to control FormMail when sending email. Options include (full list):
Exclude - Provides a semicolon-separated list of fields to exclude from the form results email. Example:
KeepLines - Some fields, such as textareas, may contain embedded newlines (also known as line breaks, returns). Normally, FormMail strips newlines from fields. If you specify this option, FormMail will keep the newlines. Example:
NoEmpty - Normally, FormMail includes all fields sent from the user's browser even if they are empty. This option tells FormMail to exclude empty fields from the email it sends you. Example:
<input type="hidden" name="mail_options" value="KeepLines" />
Example with multiple mail_options set:
<input type="hidden" name="mail_options" value="KeepLines, Exclude=submit;realname, NoEmpty" />
- Exclude - Provides a semicolon-separated list of fields to exclude from the form results email. Example:
The Tectite FormMail form processing script has many features and can be configured in a number of different ways. To use the advanced features, you will probably need to install and configure the Tectite FormMail script on your own website instead of using the FormMail script installed on the web server by the Web Team.
The Web Team is available to confer with you about your needs. However, the Web Team can provide only limited assistance.
Documentation, FAQs, and How-To Guides on the Tectite FormMail website are very thorough. In addition, you can use the Tectite FormMail Forum (message board) for support. Tectite also provides fee-based support - please confer with the Web Team before paying for support!
Some of the advanced features of FormMail include (full list):
- store form results in a CSV (comma separated values) file (not really a database) on the web server
- redirect to a specific URL on failure (customized error page)
- send HTML emails formatted with your form results
- format plain text results email using templates
- upload files
- perform advanced field validations (see info for "conditions" hidden form field)
- perform advanced error handling
- send an autoresponse to the person submitting your form
- create multiple page forms
- and more information about Tectite Formmail!