cgi form mail example

The form mail script collects the data submitted in a form, (optionally) formats it, and sends it to one or more email addresses. For more information on form mail scripts and a list of free form mail scripts see Some form mail script examples.

This page explains the usage of Perl based, NMS FormMail.

Using the form mail script

This guide takes you step by step through creating a form and getting the form submissions by email.

Step 1: Download the form mail script

Download the script from Download the TFMail package from the page and unzip it.

Step 2: Modify the script

Now you have to modify the script that you had downloaded in step 1. Open the in a text editor and update the script. Instead of ‘johnd’ it will be your user name. Depending on your hosting account, the actual path can vary.

Note: Important! do not put the configuration files in a location that could be accessed from the web.

Step 3: Update the configuration file

open the default.trc file (from the downloaded files in step 1) save it as say, feedback.trc

Edit feedback.trc and change recipient to your email address.

Step 4: Upload the files

  • Login to your web server through FTP.
  • Create a folder tfmail in the base folder
  • Note: Important! do not put the configuration files in a location that could be accessed from the web.

  • Upload the following files to the tfmail folder
    • email.trt
    • missing.trt
    • spage.trt
    • feedback.trc
    • (created in step 3)

    • Upload the to the cgi-bin folder. Update the file permissions of to 755

Step 5: Create the form

Use an HTML editor to create the form

The code for a sample form is given below:

<form name='feedback' method='POST' action='/cgi-bin/' accept-charset='UTF-8'>
<input type='hidden' name='_config' value='feedback' />
Name: <br> <input type='text' name='Name' size='20'/><br>
Email: <br> <input type='text' name='Email' size='20'/><br>
Comments: <br>
<textarea name='Comments' cols='50' rows='8'></textarea><br>
<input type='submit' name='Submit' value='Submit'/>

Upload the page containing the form also to the web server

Step 6: Test the form!

Open the form page and submit some sample data.

Comments on this entry are closed.

  • Described Very nice and easily. Thank you for this help.

  • Thanks for the tutorial and great help.

    I was able to follow all of the instructions easily enough, but when I try to submit the form, it wants to open or save the file.  What am I doing wrong?

    • Find out from your hosting service whether they support Perl. If so, where to put the perl file

  • I pretty much followed your tutorial but I want to test it locally before making it live what do I need to do?

  • am not clear,what i need is a form in which the viewers filled it and i get the message in my mail box while they also get my auto-mail response that their mail has been received will be treat as soon as i review it.

  • Thanks for the good instruction !
    Finally , I find a good form to email !
    but I got some problem ,it will submit anyway even the form is whole blank ,am i missing something ?
    this is it ,