Home Web Hosting Business Solutions Policies Support About

FormMail How-To


CGI Library
FormMail How-To
E-mail Configuration




This page will help you get started with creating a form to collect information and email it to you. We're going to build a form like the one below.

It is going to use a free CGI script called "FormMail" to read the form and email the information to you. "FormMail" is a very popular script, but earlier versions were vulnerable to SPAM exploits (in other words, someone else could send SPAM through your FormMail script and make you look bad). Be sure to use the secure version (Version 1.9s) which is available in the CGI Library.

No matter how many forms you want to have on your site, you only need one copy of FormMail.pl, even if the forms go to different recipients. The secure version of FormMail.pl requires you to specify valid recipients explicitly, and/or the domains of recipients. The more specific you are, the better, especially if you have your form email you a domain other than your site.

First, we need to define a couple of terms:

  • "Local site" refers to the working location of your web pages on your PC.

  • "Remote site" refers to the /web folder (for you FTP users) of your site on the server.


  1.  Build your page and paste the following html into it:


This should give you a form that looks like this:




  1. Finish building your page and save it within your local site.

  2. Download FormMail to your PC and unzip the files.

  3. Open FormMail.pl in a text editor (WordPad or Notepad work well).

  4. Find this line:

@recipient_addresses = ();

Enclose your email address in single quotes and put it inside the parenthesis. If you want the script to be able to email to other email addresses, separate these with commas.

@recipient_addresses = ('[email protected]','[email protected]');
  1. Alternatively, you can specify just the domain name of valid recipients on this line"

@recipient_domains = ();

Just put the domain name in single quotes, separated by commas, just like step 6 specified for email addresses.

  1. Save FormMail.pl as text.

  2. Create a cgi-bin folder within your local site, and copy FormMail.pl there.

  3. Upload the new form and FormMail.pl (and the cgi-bin folder) to your remote site.

You must perform the following steps on any CGI script you want a form to use! This is known what the scripts readme file usually refers to as "chmod 755".

  1. In FTP, navigate to the cgi-bin folder on your remote site.

/web/cgi-bin folder on remote site

  1. Right-click on FormMail.pl to select it. Most FTP programs will show a pop-up menu.

  2. Select the "CHMOD" command from the pop-up menu.

chmod command on pop-up menu

  1. Set the permission on FormMail.pl like this and click OK:

chmod settings for cgi scripts

  1. Navigate to your form in your web browser and test it out.


Problem Possible Cause
"Permission Denied" error You didn't CHMOD 755 the script you're trying to call from the form.
"Not found" error (404) The path to the CGI script is wrong. Use the full URL to the script in the "<form action= clause" to be sure its correct: (http://www.site.com/cgi-bin/FormMail.pl)

You may have a spelling or capitalization error in the "<form action=clause". Filenames and folder names are case-sensitive!

"Internal Error" Something is wrong with the script itself. It may have been uploaded in binary mode instead of ASCII (Text) mode, or you didn't close a quote or left a ";" off the end of a line.


This page gives the most basic steps for doing an email form. Read the "Readme" files that come with FormMail.pl to learn more about other variables that you can use to do things such as re-direct the browser to another page after the form is mailed, etc.



Home ] Up ]
Copyright 2005 Realm-Net Hosting