How to Set up FormMail Brad MarkleUpdated on August 26, 2026 3 Minute Read This guide shows you how to set up FormMail, the NMS Perl script that converts a contact form submission into an email message. FormMail runs as a Common Gateway Interface (CGI) script on a VPS or Dedicated Server. If you host on Shared hosting, read the warning first. Warning: FormMail is not supported on InMotion Hosting Shared hosting plans, and mail sent through it is blocked on Shared servers. The script sends mail without authenticating with a mailbox, and Shared servers block unauthenticated script-generated mail. If you host on Shared, use SMTP authentication instead, which is the recommended method for sending mail from your site: Using PHPMailer to Send Mail through PHP. Notice: Before you begin, download the FormMail “compat” package from NMS FormMail. The compat package is the easiest one to install. Set Up FormMail Customize the FormMail.pl script Un-compress the file you downloaded, then upload FormMail.pl to the cgi-bin directory. You only need FormMail.pl; the rest of the download is documentation. Open FormMail.pl and find the @referers line. Replace the example entries with your own domain, both with and without www, separated by a single space: @referers = qw(example.com www.example.com); Find the @allow_mail_to line. List the email addresses that the form is allowed to send to, separated by a single space, and remove localhost from the list: @allow_mail_to = qw([email protected] [email protected]); Save FormMail.pl. Configure your contact form Point your contact form’s action attribute at the script: <form ac Code tion="https://www.example.com/cgi-bin/FormMail.pl" method="post"> Note: Replace example.com with your own domain, and update the path if you uploaded FormMail.pl to a location other than cgi-bin. Add hidden fields to your form so FormMail knows where to send the submission. Start with the recipient field, which sets the email address the submission is sent to: <input type="hidden" name="recipient" value="[email protected],[email protected]" /> Warning: Every address you list in recipient must also appear in the @allow_mail_to line in FormMail.pl. If it does not, FormMail returns a bad recipient error page instead of sending the message. Add a subject field to set the subject line of the email: <input type="hidden" name="subject" value="From the contact form" /> Optionally, add a redirect field to send the visitor to a thank-you page after a successful submission: <input type="hidden" name="redirect" value="https://www.example.com/thankyou.html" /> Note: Replace the URL with your own thank-you page. If you leave this field out, FormMail displays its own confirmation page listing the submitted fields. Change file permissions Important: Set the permissions on FormMail.pl to 755. The file needs execute permission, or the web server cannot run the script and your contact form returns an error instead of sending mail. Change permissions using cPanel Log in to cPanel. Under Files, click File Manager. Navigate to public_html, then cgi-bin. Right-click FormMail.pl and select Change Permissions. You can also select the file and click Permissions in the toolbar. Set User to read, write, and execute (rwx), and set Group and World to read and execute (r-x). Click Change Permissions to save. Change permissions using SFTP If you manage your files with a Secure File Transfer Protocol (SFTP) client instead, connect to your server, browse to the cgi-bin directory, and right-click FormMail.pl. Choose the option for changing file permissions, which most clients label File Permissions or CHMOD, then set the value to 755. Your FormMail script is now set up and ready to process submissions from your contact form. Submit a test entry to confirm mail arrives at the address you configured. If delivery does not go through, check that the recipient address also appears in the @allow_mail_to line. Summarize and Research with AIShare on Social Media Related Articles Transferring Emails from Your Old Host to InMotion Hosting How to Set up FormMail SSL Certificate Lifetimes Shrink to 47 Days by 2029 Installing SSLs and Generating CSRs in cPanel How to Upload Large Files Without FTP Timeouts eCommerce – Setup your Merchant Account Gateway How to Zip and Unzip Files on Windows 11 and Windows 10 How to Transfer and Backup Website Files with Rsync .htaccess File Reference List: Rules, Fixes, and Uses How to Force a File Download With .htaccess