In this guide, you can learn how to set up the NMS FormMail script.
NOTICE: You will need to download the NMS FormMail script. Make sure to download the “compat” package.
Set Up FormMail
Customize FormMail.pl Script
Un-compress the downloaded file and upload the FormMail.pl script to your cgi-bin (you will only need to upload the FormMail.pl file, all other files are documentation).
The first is the @referers line. Replace everything inside of the parentheses with your domain, once without the www and then a single space and again with the www You will need to do this for each domain that you will be sending from. Remember, only one space between each url. The line should look like the example below:
@referers = qw(example.com www.example.com);
Now, modify the @allow_mail_to line. Here you specify any email addresses that the forms will send to. Again, only one space between multiple email addresses. Also, make sure you remove the ‘localhost’ entry. The line should look like the example below:
Save the FormMail.
The next step is to modify the FormMail.pl that is inside your cgi-bin. There are only two lines that you will need to modify.
Configure Contact Form
First, point the action of the form tag to the FormMail.pl script inside the cgi-bin.
Pointing the the contact form to the FormMail.pl
The following tag is necessary for your contact form to process the values in the form. Copy the code (below) and paste it into your Contact form’s code.
<form action=”https://www.example.com/cgi-bin/FormMail.pl” method=”post”>
NOTE: Be sure to replace example.com, with your actual domain name and /cgi-bin/FormMail.pl with the relative path to the file located on your server.
Inside of your form you will also need to include a few hidden input tags. Copy the code (below) and paste it into your contact form’s code.
Add the recipient(s) of the email:
This tag will configure the form to send to the specified email address(es).
Create the subject of the email:
This tag tells the form the subject to create the email with.
<input type=”hidden” name=”subject” value=”From the contact form” />
Redirecting the page to your own “Thank You” page
This is another optional tag to specify where your users will be redirected to after they click the submit button. If you do not include this they will be directed to a very generic looking page created by the FormMail script.
<input type=”hidden” name=”redirect” value=”https://www.example.com/thankyou.html” />
NOTE: Make sure to replace example.com/thankyou.html with the actual page that you create for redirecting your visitor after a submission is made.
Change File Permissions
IMPORTANT: One last thing that must be performed in order for the FormMail to work is that you must set the permissions on the FormMail.pl file to 755.
Change Permissions Using cPanel
Log into cPanel.
Click on the File Manager icon under the Files subheader.
Browse to the cgi-bin by clicking on the folder icons for public_html > cgi-bin.
Once inside of the cgi-bin directory, right-click on the FormMail.pl file and click to select Change Permissions.
Click the checkboxes to ensure that the User column has read, write, and execute checked and Group and World should have read and execute checked.
Click the Change Permissions button to save these changes.
Change Permissions Using FTP
If you are using an FTP client you will want to browse to the cgi-bin directory. Then right click on the FormMail.pl file and look for an option called CHMOD. This will open a dialog box where you can make the same changes as described in the cPanel file manager steps above. Make sure execute is turned on for all types of users and that the numbers have changed to 755.
Congratulations! Now you have a FormMail.pl script set up that you can use to send email from a contact form on your website.