Installing a standalone form to mail script

Download a suitable form to mail script, such as the script available at <a href="http://nms-cgi.sourceforge.net/scripts.shtml" target="_blank">http://nms-cgi.sourceforge.net/scripts.shtml</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.
$DEBUGGING = 1;

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(dave.org.uk 209.207.222.64 localhost);

For instance, if your domain name is mydomain.com, and your IP is 1.2.3.4, your referers would look like this:
@referers = qw(mydomain.com www.mydomain.com 1.2.3.4 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 some.one.else@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="http://www.mydomain.com/cgi-bin/scriptname.pl"

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

form method="post" action="http://mydomain.com/cgi-bin/scriptname.pl"


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.

  • 0 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

EMAIL: Deferred mail when sending to Yahoo

Issue: Mail sent to Yahoo-based addresses, particularly from mailing lists or forms, results in a...

How can I reduce the amount spam I receive?

The following steps will help to dramatically reduce the amount of spam seen in your mailbox.1....

Cannot send email: No valid recipient error

Symptom: Client using Outlook reports that sending mail fails with an undeliverable notice. The...

How do I set a filter to delete spam using Mailscanner

Standalone filters are unnecessary. To delete mail tagged as spam by Mailscanner, choose the...

Email: Not receiving email

Symptom: Client is not receiving email at one or more mailboxes under their account.Cause: Most...