How to Set up FormMail

In this guide, you can learn how to set up the NMS FormMail script.

Set Up FormMail

Customize FormMail.pl Script

  1. 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 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.
  2. 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);
  3. 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:@allow_mail_to = qw([email protected] [email protected]);
  4. Save the FormMail.

Configure Contact Form

  1. 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”>

  2. 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).<input type=”hidden” name=”recipient” value=”[email protected],[email protected]” />

    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” />

Change File Permissions

  1. Log into cPanel.
  2. Click on the File Manager icon under the Files subheader.
  3. Browse to the cgi-bin by clicking on the folder icons for public_html > cgi-bin.
  4. Once inside of the cgi-bin directory, right-click on the FormMail.pl file and click to select Change Permissions.
  5. 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.
  6. 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-bindirectory. 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.

NOTE: We have written a dedicated article on creating a contact form with FormMail.pl script. That is the next step of this article.

If you enjoyed this article, then you’ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! Check out our services.