My formmail script is not working. Why?

Fast, reliable, and now featuring free SmarterMail with all Linux Cloud Spaces Plans Most times, Formmail scripts fail due to the configuration section of the script. You must go through and verify that each variable is initialized properly.

$mailprog: If you downloaded the Formmail script from our Knowledge Base, then you shouldn’t have to edit this variable. It should, however, read:

$mailprog = ‘c:/perl/bin/blat.exe’;

$tempdir: This is the path on your site where the message is stored before it is processed by Blat and sent. It should be set to a directory with write permissions. We recommend setting it to your CGI-BIN path. All data on our servers is on the D: drive so your path should look something like this:


$logfile: This is where the log file is stored if $uselog is equal to 1. This should also be a path on your site where write permissions are enabled. We also recommend that you use your CGI-BIN for this path as well since it by default has write permissions enabled. It should look similar to the $tempdir variable with one exception as it specifies the log file name as well. Here is an example:


@referers: This is probably where most Formmail problems originate. If you are getting a gray error message box saying “Invalid Referer”, this is what needs to be fixed. This array of IP addresses and domain names tells the Formmail script who can submit this form. Here is an example of the referrers variable:

@referers = (‘’,’’, ‘’);

The referrers variable should also contain the domain name of where you are going to be sending the message. In the example above, you can see listed.

The last variable which must be set is the @recipients. If you included the domain name of where you are sending the message in the @referers variable, then the following example will work fine:

@referers = @recipients;

The only other place for error is in the form itself. The form requires three hidden fields which are:

<input type=hidden name="recipient" value="">
<input type=hidden name="subject" value="Test">
<input type=hidden name="redirect" value="Thanks.html">

The recipient’s domain name (in the example, must match an entry in the referer’s variable. The subject is what will come across when you receive the results of the submitted form. And, the redirect is the URL to the file which will thank them for submitting the form.

If you have any questions regarding Formmail after reading this article, please don’t hesitate to contact our support department.

Add Feedback