1and1 Help Centre Categories

print article

Configure the FormMail.pl Script

This article only applies to Linux packages, with the exclusion of the Linux Beginner package.

If you have not already downloaded the FormMail script, please reference What FormMail script should I use?Open the FormMail.pl script in a basic text editor such as Wordpad, Notepad, Notepad++ or using a text editor through SSH such as nano or vim. The lines of importance are listed below.

Line 1      #!/usr/bin_uk/perl -wT
Line 44 $mailprog = '/usr/lib/sendmail -t -i ';
Line 45 $postmaster = '';
Line 46 @referers = qw(dave.org.uk 209.207.222.64 localhost);
Line 47 @allow_mail_to = qw(you@your.domain some.one.else@your.domain localhost);
  • Line 1: This is the location of Perl on the 1&1 servers. Change this line to:
    #!/usr/bin_uk/perl   

  • Line 44: The system command that the script should invoke to send an outgoing email. You will also need to include the recipient's e-mail address on this line. On 1&1 servers the sendmail system is located in /usr/sbin/sendmail so this line will need to be changed to:
    $mailprog = '/usr/sbin/sendmail yourEmail@yourDomain.com';   

  • Line 45: The envelope sender address to use for all e-mails sent by the script. This address will receive bounce messages if any of the e-mails cannot be delivered so put your e-mail address here as well:
    $postmaster = 'yourEmail@yourDomain.com';   

  • Line 46: A list of referring hosts. This should be a list of domain names of all websites that will use this domain. Only these hosts will be allowed to use the formmail script. This can be used to prevent others from linking to FormMail.pl from their own HTML forms.
    @referers = qw(yourDomain.com myWebsite.com);   

  • Line 47: A list of the e-mail addresses that FormMail can send e-mail to. This will also prevent abuse of your FormMail script so that the form can not be used to send SPAM unauthorized recipients. The values of this list can be either simple e-mail addresses (like 'yourEmail@yourDomain.com') or domain names (like 'yourDomain.com'). If a domain name is used then *any* address at the domain will be allowed to receive e-mails from the FormMail script.
    @allow_mail_to = qw(yourEmail@yourDomain.com);   

A configured version should look like this (with important lines in red):

#!/usr/bin_uk/perl
#
# NMS FormMail Version 3.14c1
#

use strict;
use vars qw(
 $DEBUGGING $emulate_matts_code $secure %more_config
 $allow_empty_ref $max_recipients $mailprog @referers
 @allow_mail_to @recipients %recipient_alias
 @valid_ENV $date_fmt $style $send_confirmation_mail
 $confirmation_text $locale $charset $no_content
 $double_spacing $wrap_text $wrap_style $postmaster
 $address_style
);

# PROGRAM INFORMATION
# -------------------
# FormMail.pl Version 3.14c1
#
# This program is licensed in the same way as Perl
# itself. You are free to choose between the GNU Public
# License <http://www.gnu.org/licenses/gpl.html> or
# the Artistic License
# <http://www.perl.com/pub/a/language/misc/Artistic.html>
#
# For help on configuration or installation see the
# README file or the POD documentation at the end of
# this file.

# USER CONFIGURATION SECTION
# --------------------------
# Modify these to your own settings. You might have to
# contact your system administrator if you do not run
# your own web server. If the purpose of these
# parameters seems unclear, please see the README file.
#
BEGIN
{
 $DEBUGGING         = 1;
 $emulate_matts_code= 0;
 $secure            = 1;
 $allow_empty_ref   = 1;
 $max_recipients    = 5;
 $mailprog          = '/usr/sbin/sendmail yourEmail@yourDomain.com';
 $postmaster        = 'yourEmail@yourDomain.com';
 @referers          = qw(yourDomain.com myWebsite.com);
 @allow_mail_to     = qw(yourEmail@yourDomain.com);
 @recipients        = ();
 %recipient_alias   = ();
 @valid_ENV         = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
 $locale            = '';
 $charset           = 'iso-8859-1';
 $date_fmt          = '%A, %B %d, %Y at %H:%M:%S';
 $style             = '/css/nms.css';
 $no_content        = 0;
 $double_spacing    = 1;
 $wrap_text         = 0;
 $wrap_style        = 1;
 $address_style     = 0;
 $send_confirmation_mail = 0;
 $confirmation_text = <<'END_OF_CONFIRMATION';
From: you@your
Subject: form submission

;Thank you for your form submission.

END_OF_CONFIRMATION   
Once uploaded you will need to change the permissions of the file so that it can be executed. You can do this vis SSH by using the following command in the same folder where the script is saved:

chmod 705 FormMail.pl

or you can do this via your FTP program by using the numeric/octal permissions 705 for the file or enabling permissions manually for: Owner: Read, Write and ExecuteGroup: NonePublic/Others: Read and Execute