HSC Web Authors

UNM HSC Mail Form Mailer

The HSC Mail Form Mailer will process any form whose action attribute is pointed at the cfmailer file: [http://hsc.unm.edu/scripts/cfmailform/cfmailer.cfm]. By placing a handful of hidden input objects in your form, a user can click the submit button and be assured that it will end up in your designated inbox. This document will cover those hidden objects that are required and those that are optional so that you can successfully create an HTML email form for your web site.

 

Let’s build a basic web form:

<h1>Sample Email Form</h1>

<form action="http://hsc.unm.edu/scripts/cfmailform/cfmailer.cfm" method="post">

<!-- Required hidden operators -->

<input type= "hidden" name="recipient" value="you@salud.unm.edu" />

<input type= "hidden" name="subject" value= "Sample Email Form" />

<input type= "hidden" name="redirect" value="http://hsc.unm.edu/mysite/emailsucess.html" />

 

<!-- Field validation for the user -->

<input type= "hidden" name="sender_required" value="You must enter your email address to submit this form." />

<input type= "hidden" name="yourname_required" value="Enter your name please." />

<input type= "hidden" name="birthday_date" value="Birth date must be an actual date." />

<input type= "hidden" name="birthday_required" value="Birth date is required." />

 

<!-- Our form in HTML -->

<p>Name: <input type="text" name="yourname" value="" /></p>

<p>Email Address: <input type="text" name="sender" value="" /></p>

<p>Things I like:</p>

<ul>

<li><input name="Things_I_Like" type="checkbox" value="Pie" /> Pie</li>

<li><input name="Things_I_Like" type="checkbox" value="Cake" /> Cake</li>

<li><input name="Things_I_Like" type="checkbox" value="Ice Cream" /> Ice Cream</li>

</ul>

<p>Your birthday: <input name="birthday" type="text" value="" /></p>

<p>Comments:<br /><textarea name="Comment"></textarea></p>

 

<p><input type="submit" name="submit" value="Send This Form" /></p>

</form>

 

For the form to work, the following hidden operators need to be completed to send an email.

  • recipient: contains the email address of the person or account that should receive the user’s form
  • subject: contains the text for the subject line of the email, make it something distinct so that it can easily be found in a full in-box
  • redirect: contains a fully qualified url that you would like the user to see upon a successful sent email, create a thank you page with contact information so a user feels like they can follow up with a responsible party

 

Optional hidden operators:

  • cc: additional individuals to send the email to
  • bcc: additional individuals to send the email to, but who are hidden from all other recipients

 

Your form can contain any number of elements and widgets to help users successfully send information to you. However, there are a few rules to watch out for.

  • Form field names may not have spaces it them (i.e. “primary street address” is not a valid field name)
  • Make your forms easy to understand and include instructions to help users successfully complete and return the information you need
  • Some form elements, if left blank by a user will return an empty string (i.e. a text box for “middle_initial” that is left empty will show up in the email as “middle_initial = ”)
  • Some form elements, if left blank by a user will not included in your email (i.e. unchecked radio buttons and check boxes will not be processed or reported)
  • There are a handful of reserved words that may not be used in the name of form fields (see end of document for a list)
  • The submit button must always be named “submit”, however you can make the button label contain any text you want by changing the “value” attribute.

 

There are several command words used by the form processor that will help you validate the user input before it is sent by email. You can use them in any combination and stack them. In the example form we have made a date field validate as an actual date and made it a required field.

 

To create required fields that will stop the email from being sent and alert the user to fix their form follow these steps:

 

  1. build an input object with a name you choose
  2. create a copy of that object and add “_required” to the end of the field name
  3. write an explanation that this form field is required in the value attribute of the newly copied input object
  4. the new input tag may be located in any part of the form, but it is good style to list them early in the form document

 

There are several validation types you can use:

  • _required: will make an element on the form required for submission
  • _integer: will require the field to be a valid whole number (i.e. 1, 3, 277, 10,948)
  • _float: will require the field to be a valid decimal number (i.e. 1.5, 3.1476, -.3)
  • _date: will require the field to be a valid date (can be entered in most any method though)
  • _time: will require the field to be a valid time entry

 

When the email is sent, the designated recipient will receive a list of all the fields with the information the user entered. For example, if I answer the form above this sample email will be sent:

 

 

Reserved words not to be used in general field names (they have special uses as described above):

  • Recipient
  • Subject
  • Redirect
  • Cc
  • Bcc
  • Submit
  • Required
  • Date
  • Time
  • Integer
  • Float
  • Range