Form Submission Handling

This document explains how to set up a script to e-mail HTML form submission results. This information can be useful if you host a site with us and wish to utilize a contact form. These instructions assume a basic knowledge of HTML forms and how they work.

The setup uses a special script written in the ColdFusion Markup Language which executes on our server when your form is submitted to it (similar to how a CGI program works). The script then assembles the submitted form fields into an e-mail message and sends it to the address(es) specified in the script. The script can then display a page to the user confirming the submission (a "thank you" page), or redirect the browser to a different URL (eg. to an existing confirmation page).

Here are the steps to getting the script set up and working for you:

  1. Download the script here
  2. De-compress FormMail.cfm from the zip file and save it somewhere with the rest of your Web site files. The zip file also contains a simple HTML form for example and testing purposes.
  3. Open FormMail.cfm in a plain-text editor (eg. Notepad, or SimpleText, NOT Word or Wordpad). You will need to edit at least 3 items in this file:
    1. Line #7: <cfset mailTo = ""> -- specify the e-mail address to which the form contents should be sent. You may specify more than one address here, separated by commas. Enter only the bare e-mail address, without any quotes, brackets, real name, etc.
    2. Line #12: <cfset mailFrom = "'Web Form Submission' <>"> -- specify email address and (optionally) name to send form submission from. Use the example format to specify a "name" to appear in the From line of the email if you wish, or just specify a bare e-mail address. It is recommended that you use a different address here than the mailTo address, in case there are problems delivering to the mailTo address, the problem report would be mailed to the mailFrom address.
    3. Line #15: <cfset mailSubject = "Web site Contact form submission"> -- specify the desired Subject line of the e-mail to be sent.
  4. Scroll down to line #46 in FormMail.cfm. From here on you can modify what the user sees after the form is submitted. There are 2 options to choose from:
    1. Remove the comments around the <cflocation> tag on line #48, and provide a URL to redirect the browser to. For example, if you have a page named "thankyou.html" which you would like to display to the user after they submit the form, you would use <cflocation url="thankyou.html"> (This is assuming that thankyou.html is in the same directory as FormMail.cfm on the server. If it isn't, use standard URL techniques to specify the correct path, eg. "../OtherDir/thankyou.html" or "/OtherDir/thankyou.html" or "")
    2. The other option is to simply create or paste in your confirmation page HTML right into FormMail.cfm, as shown in the example in the script (line #50 and on). This should be a complete HTML page, with head/body tags, etc.
  5. Once you are done editing FormMail.cfm, save it. You will need to upload this file to a directory of your choice within your site's WebRoot folder on our server. You may place it right in the WebRoot directory if you wish.
  6. Now edit your HTML form:
    1. Change the action attribute of your form tag to point to FormMail.cfm, wherever you saved it on the server. Eg. <form action="scripts/FormMail.cfm" method="post">
    2. Check the names of your form fields. They must not start with a number (eg. "4YourInfo"), and should not contain any spaces. The names you choose will appear in the generated email, so it helps to make them descriptive. Do not specify a name attribute for the Submit button, otherwise it will also show up in the generated e-mail.
  7. Save and upload your form, and do a test submission. If it works, an email should be sent to the address you specified in the mailTo parameter, and you should see the confirmation page you specified. In case of trouble, double check all the above steps. If you get an error message after submitting the form, it should contain useful information to help troubleshoot the problem.

Hopefully this will get you up and running with basic form submission handling. If you need something more customized, you could use ColdFusion scripting to program the additional functionality you need, or contact us for further assistance. If you run into an issue you can't solve, please contact us via e-mail at or the contact form on our Hosting Client Support page.