FormMail is a very popular script that you can put onto your website so that visitors can fill it out and have their response emailed directly to you. To help you set up FormMail on your website we have written a step-by-step guide to installing and configuring FormMail: If you missed our previous article, please see the How Contact Forms Work tutorial.
- Download the “compat” version of the NMS FormMail script.
- Un-zip the downloaded file and upload the FormMail.pl script to your cgi-bin folder in your public_html folder.
- Next you will need to modify the FormMail.pl file that was uploaded into your cgi-bin folder. First, you will need to change the @referers line (around line 47). Replace everything inside of the parentheses with your domain using the same formatting, once without the www and then a single space and again with the www.
- This is where you input any email addresses that the forms will send to. Make sure you remove localhost from both the @referers and the @allow_mail_to lines (around lines 47 and 48, respectively.) Once you have made these two changes, save the file.
- After adding the code to the page that you want the form on, you will need to point the action of the FORM tag to the FormMail.pl script inside the cgi-bin folder:
<form action="http://www.example.com/cgi-bin/FormMail.pl" method="post">
- Next, inside of each of your forms you will need to include a few hidden input tags. They are detailed below:
<input type="hidden" name="recipient" value="firstname.lastname@example.org,email@example.com" />
This tag tells the form which email address to send the form to. Just make sure that this email is one of the addresses in your @allow_mail_to field
<input type="hidden" name="subject" value="From the feedback form" />
This is a optional tag you can input into your form to specify the subject line of the email that gets delivered to you.
<input type="hidden" name="redirect" value="http://www.your.domain/foo.html" />
This is another optional tag to specify where your users will be redirected to after they click the submit button.
Updates for Shared Servers
If you are creating a form on a shared server (business class account), then all form feedback will automatically be set to come from “nobody”. This was done in order to be able to add an email origin for emails coming from scripts on shared servers. The main purpose for this setting was to help stop spam. Previously, messages generated from scripts were difficult to track. Setting the form to use the email systems on the server helps to reduce load on the server.
You can set the form to use SMTP by looking for the following line in the FormMail.pl script:
$mailprog = ‘/usr/lib/sendmail -oi -t’;
Then, you would replace it with:
$mailprog = ‘SMTP:mail.DomainName.com’;
If you require help finding your email server settings, please see “How to Find Email Settings.”