You are here: Home » All Posts » Form mail scripts » cgi form mail example

cgi form mail example

in Form mail scripts

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 http://nms-cgi.sourceforge.net/scripts.shtml 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 TFMail.pl 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
    • MIME_Lite.pm
    • NMSCharset.pm
    • NMStreq.pm
    • email.trt
    • missing.trt
    • spage.trt
    • feedback.trc
    • (created in step 3)

    • Upload the TFmail.pl to the cgi-bin folder. Update the file permissions of TFmail.pl 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/TFmail.pl' 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>
<br>
<input type='submit' name='Submit' value='Submit'/>
</form>

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.

Be Sociable, Share!
Stalin March 31, 2011 at 11:47 am

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

Morgan April 26, 2011 at 11:47 pm

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 tfmail.pl file.  What am I doing wrong?

Prasanth April 27, 2011 at 4:01 am

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

axlefoley September 5, 2011 at 2:57 pm

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

Prasanth September 16, 2011 at 7:43 am
positive September 19, 2011 at 11:36 pm

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.

Jackie March 7, 2012 at 1:16 pm

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 ,
http://cosxlighting.com/Untitled-1.html
thanks

Comments on this entry are closed.

Previous post:

Next post: