From Lunarpages Web Hosting Wiki
How do I configure formmail?
Due to abuse by spammers, we have had to stop the use of the old formmail script on our servers.
For email forms we recommend using the NMS scripts at http://nms-cgi.sourceforge.net/scripts.shtml because they were written to be more secure, using strict settings. It does come with instructions and we do have instructions on these scripts in our forum:
Please do not name your script using the words mail, formmail, or contact. Our servers are contantly being scanned for these names and if a form is found with these names it will be disabled. You will need to change the name of the nms scripts to follow this as well.
Be sure the path to perl in the script is:
And that the script is uploaded to cgi-bin in ASCII mode. Permission should be set to 755. You may edit and change permissions in the File Manager by clicking on the filename and choosing Change Permissions from the menu in the upper right. File Manager may or may not upload the script in the right mode. You may need to upload with an FTP program and tell the program to upload in ASCII mode. You can also change permissions with an FTP program.
Editing the script
You will need to edit several sections in the formmail.pl file to make it work properly. This can be done in notepad or a similar text editor. Under User Configuration Section there is the following (change bold parts):
$mailprog = '/usr/sbin/sendmail -oi -t'; $postmaster = "; @referers = qw(dave.org.uk 184.108.40.206 localhost); @allow_mail_to = qw(email@example.com firstname.lastname@example.org localhost);\ @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: email@example.com Subject: form submission Thank you for your form submission. END_OF_CONFIRMATION
Make sure to change the first line: $mailprog = '/usr/sbin/sendmail -oi -t';
Also change the @allow_mail_to an existing email address on your site, and the other bold sections.
The .pl file needs to be renamed
As mentioned above, you will need to rename the formmail.pl file to something else. The new filename should not include the words mail, formmail, or contact.
After these changes have been made, you can upload the file to your /public_html/cgi-bin/ folder and then change the permissions to 755.
How to Get the Form working in HTML
For your form on the site you can go to it and view the source. Do a search for post and you will see something like:
<form action="tfmail.php" method="post" name="form1" id="form1">
If you named the formmail file example.pl, then the action would look like this:
<form action="cgi-bin/example.pl" method="post">