Installing a standalone form to mail script

Download a suitable form to mail script, such as the script available at <a href="" target="_blank"></a> - this is the script we recommend, and the following walkthrough is based on this script.

The compat version should be chosen, in either the .tar.gz or .zip format, depending on which is easier for you to extract.

Extract the archive. Open the script in your favorite text editor so the variables can be set. For most people, the default values will be sufficient, with the following changes:

Change the following value from 1 to 0 after the script is live. Do not leave the debug option set to 1 when the script is live.

Change the following value from 5 to the actual number of recipients your form is designed to mail. For most people, the maximum number of recipients will be 1.
$max_recipients = 5;

Change the following value to your own domain information.
@referers = qw( localhost);

For instance, if your domain name is, and your IP is, your referers would look like this:
@referers = qw( localhost);

Multiple items are separated by a space. Only the referers listed in this parameter will be permitted to use this script.

Change the following value(s) to the recipients of the form:
@allow_mail_to = qw(you@your.domain localhost);

Do not leave localhost in this parameter, as there is no valid reason for it. If the recipient can be any user at your domain, only the domain name (not a full email address) is required. This will permit the script to be used for multiple forms on the same site without a separate copy or complete list of allowed recipients. If there is only a single form, and only one or two recipients allowed, it is better for security reasons to specifically define those recipients in the script.

Change this value to either a style sheet in use on the site or to 0 or an empty string if no stylesheet is to be used:
$style = '/css/nms.css';

More advanced options are available for the script. Details for those options are available in the README file within the distribution package.

Save the file and upload to your account. Typically, scripts of this nature will be placed in the cgi-bin directory.

Rename the script to anything other than a variation of formmail.*, FormMail.*, or Formmail.*, as these names are filtered and cannot be used. Change the permissions on the script to 755 (rwxr-xr-x).

The script can then be called within the HTML code of the form. Code that previously used the systemwide form to mail script (/cgi-sys/FormMail.cgi) should be modified to use the new script instead. Typically, the POST code will be one of the following:

form method="post" action=""

form method="post" action="/home/myusername/public_html/cgi-bin/"

form method="post" action=""

Many of the same values used by any generic or by the systemwide script, such as subject, redirect, and return link URL can be set within the code. Full details of all variables can be found in the README file included with the package distribution.

In the most general of cases, most people will need only set the variables in the script itself and then replace the code used to post the form data, as this script is designed to be a dropin replacement for Matt Wright's script, which is banned on our servers - and which is what the systemwide FormMail clone is based on as well.

  • 3 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

PHP script error: FATAL ERROR: register_globals is disabled in php.ini, please enable it!

<b>Symptom: </b>The following error appears on a site running a php-based...

HOW TO: Combat referer spam/block certain referers

Symptom: A client wishes to deny access to their site (or parts of it) when the traffic is...

Expression Engine installation generates "variable references" error

Symptom: Expression Engine installations older than version 1.3.1 generate an "Only variable...

My phpBB forum installation is not accessible

Symptom: Client cannot access phpBB forum installation. Permissions on the forum installation...

Enabling register_globals

Symptom: A client's script requires that register_globals be enabled.Resolution: Globals are not...