InMotion Hosting Support Center

Here is a walk through on setting up the NMS FormMail script.

See Also: Preventing SPAM in FormMail

You will need to download the NMS FormMail script. Make sure to download the "compat" version.

Steps for setting up FormMail

  1. Un-compress the downloaded file and upload the script to your cgi-bin (you will only need to upload the file, all other files are documentation).
  2. The next step is to modify the that is inside your cgi-bin. There are only two lines that you will need to modify. 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.
  3. This is where you input any email addresses that the forms will send to. Again, only one space between multiple email addresses. Also, make sure you remove 'localhost' from both the @referers and the @allow_mail_to lines.
  4. Now you can save the FormMail and proceed to modifying your forms.
  5. First, point the action of the FORM tag to the script inside the cgi-bin:

    Pointing the the contact form to the

    The following tag is necessary for the form to process the values in the form. Make sure the action points to the correct location on your server. The following is an example.

  6. Next, inside of each of your forms you will need to include a few hidden input tags. Copy the code in the text box and paste it into your Contact form. They are detailed below:

    Add the recipient(s) of the email

    This tag will configure the form to send to a specific email or email addresses.

    Create the subject of the email

    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

    Redirecting the page to your own "Thank You" page

    This is a optional tag you can input into your form to redirect your form to your own 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.

    Important! One last thing that must be performed in order for the FormMail to work is that you must set the permissions on the to 755. This can be done either inside our control panel from the file manager or from an FTP client like SmartFTP or WS_FTP.

If you are using the file manger you will want to browse to the cgi-bin by clicking on the folder icons for public_html > cgi-bin. Once inside of the cgi-bin click on the text title for and take notice of the text links that appear in the upper right hand corner of the screen. One of them is Change Permissions. Click this and click all the check boxes for Execute. This will change the numbers at the bottom to 755. Click Change, and your all done.

If you are using an FTP client you will want to browse to the cgi-bin. Then right click on the and look for an option called CHMOD. This will open a dialog box where you can make the same changes as in our file manager. Make sure execute is turned on for all types of users and that the numbers have changed to 755.

If you have any questions on how to set this up please feel free to send an email to

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
How to set up cgiemail? will not send own made thank you page
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2017-05-19 12:25 am

Looks like this only gives 500 error. Runs ok on command line producing kinda html code to screen, but no errors.

perl version is 5.24.0

kernel 4.10.10

How to start looking where problem is?

2,858 Points
2017-05-19 11:53 am
Antsu, I would recommend reviewing our article about common causes of 500 errors.
n/a Points
2017-02-21 7:19 am

I have placed my .pl file in the cgi-bin folder, but I'm still getting, "The requested URL /cgi-bin/ was not found on this server." Please help resolve this issue.

2,858 Points
2017-02-21 3:46 pm
David, make sure that your form HTML tag has 'action=""' as the listed action, where the value for 'action' is your domain. Alternatively, you may be able to use just "cgi-bin/", but this may depend on your hosting setup.

Next, I would check to make sure that your permissions are set properly for your 'cgi-bin' folder, as well as your '' file.

If neither of those resolves the issue and your web host is using cPanel, I would make sure that your 'homedir', and 'scriptalias' for the domain you are trying to set this up on are configured properly.
n/a Points
2016-11-29 10:31 am
Solution urgent. My website is and my domain email id is My problem is my website contact form is directly sending from email But I want to use my Gmail address.
10,059 Points
2016-11-29 11:12 am
You must make sure that you are using SMTP settings for your gmail address in your mail form.
n/a Points
2016-11-20 1:34 am

Thank you for the help with this script. I have some questions however..


I have successfully received the email including the form information, but..

The email I receive is from "nobody@blablabla" I attempted to add an email text box as mentioned above with no success. 

The subject line does not show as I entered it.

The thank you page does not redirect to my own page and uses the default. I have gone through and looked at your steps and my code but cannot seem to fix it.


I appreciate your help!!

43,761 Points
2016-11-21 6:56 pm
Without seeing the actual code to compare, it is very difficult to say. Are you getting any error messages at any point? Be sure to go back through your code and ensure all the correct variables were changed to the settings you desire.
13,821 Points
2016-11-15 1:22 pm
I'd suggest at using something like reCaptcha. Here's a link that may help you out:
n/a Points
2016-11-15 7:15 am

I'd like to put an IF statement in somehow whereby the user sees "what's 5 x 6?" and must enter 30 then I check that the answer is 30 or wont' send the form. Getting a lot of spam. Can it be done?

n/a Points
2016-05-28 9:40 pm


I see there is a required function in the form but it isn't yet clear (to me) how to engage this to assure specified required fields must be present. How do we dop that? (Thanks InMo team!)

43,761 Points
2016-05-31 10:37 am
If you wish to force requirements for specific fields, you would need to code those handlers in the perl script. You can also add them in JavaScript to guide the visitor along. However, never just use JavaScript as it can be disabled from the client side and bypassed. Always check with your server side script (Perl, PHP, etc)
n/a Points
2015-12-22 9:55 am

all code try but  when click on send  value are clear and not receve any mail

10,077 Points
2015-12-22 11:55 am
Hello Jagdish,

Did you copy the code completely or have you made modifications? Have you tried to turn on error reporting to see if you are getting any PHP errors?

Best Regards,
TJ Edens
n/a Points
2015-12-03 5:54 pm

using your form is it possible to send the reply to two different email's?

30,400 Points
2015-12-03 8:16 pm
Hello Barry,

Thank you for contacting us. Yes, "Step 3" above explains how to input any email addresses that the forms will send to..

If you have any further questions, feel free to post them below.

Thank you,
n/a Points
2015-10-07 9:16 am

Hi ,

I've conffigured the as per steps above and still it will not work, also done it correctly in the Form as well.


What else can I do to make it work?

40,371 Points
2015-10-07 5:51 pm
Hello Kisubiboy,

Sorry for the problem with the Form. However, in order to help you we would need more information. If you are hosted with us, please provide us some account information so that we can look at where you have implemented the form. Do you get any error messages? Can you provide us a copy of the code you saved? We can't determine why the form is not working without a little more info.

Kindest regards,
Arnel C.
n/a Points
2015-09-10 5:11 pm

Is there a way to import a list into the mailform? I am currently using Mailchimp to send out a daily HTML of our site to out 560+ subscribers and I would liek to import them into the site


43,761 Points
2015-09-14 9:49 am
Hello Stephen,

Not by default as this is a simple script setup. You could of course code your own import where it stored the list in a database and sent out mails using that list. That is not part of this article, however.

Kindest Regards,
Scott M
n/a Points
2015-05-26 10:54 pm

If i want to add attachment to the form, how can i do it? Thanks for the help.


40,371 Points
2015-05-28 2:18 pm
Hello David,

Probably the easiest way to add the attachment would be to simply go to the HTML portion of the email form and add a link to the attachment that you wish to add.

I hope that helps to answer your question! If you require further assistance, please let us know!

Arnel C.
n/a Points
2015-04-03 10:04 am

I did everything as u mentioned but its giving 502 gateway error... Please Help me with this...





40,371 Points
2015-04-03 3:14 pm
Hello Gourav Batra,
Sorry to hear that you're having problems with the 502 gateway error. There are MANY things that a 502 bad gateway error could be. We need more specific info on the account and how you're getting the error, please. If you can provide more information, then we can look further into the problem that you are having.

Kindest regards,
Arnel C.
n/a Points
2014-08-27 2:35 pm

sorry I dont see the post but I see a duplicate of the first post. I will try again.

<form action="" method="post" > <input type="hidden" name="recipient" value="," /> <input type="hidden" name="subject" value="From the feedback form" /> <input type="hidden" name="redirect" value="" /> <input type="hidden" name="reset" value="reset"/> Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    <input type="text" name="name" style="width: 385px"/><br />   <br/> Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    <input type="text" name="email" style="width: 379px"/><br />   <br/> Comments:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     <span class="auto-style4">    <textarea name="comments" class="auto-style5" style="width: 408px; height: 166px" rows="1"></textarea></span><br />   <br />

  <INPUT TYPE="submit" value="Send e-mail"/> <INPUT TYPE="reset" value="reset"/></FORM> 

40,371 Points
2014-08-27 2:48 pm
Hello Ed,

We do appreciate the comments and questions. In the future, if there's anyway that you can consolidate the code to as few posts as possible, then we can reply to them much quicker.

I went through your code with Jeff, and it all appears normal to us. The form looks okay as well. On our servers this script is meant to run as a Perl script, so that might be the issue. You may need to talk with your host to see why the script is running completely. Or at least why the email portion is failing to send you a message. They may need to check the logs to see if they can find any error or indication of the mail being processed at the server.

Apologies that we can't give a direct answer. Hopefully, this does lead you to a solution. Please let us know if you have any further questions or comments.

Arnel C.
n/a Points
2014-08-27 2:16 pm
Below is my form code Name:                       Email:                        Comments:          Thanks Ed

I get a confirmation page but do not get email?

$DEBUGGING         = 1;  $emulate_matts_code= 0;  $secure            = 1;  $allow_empty_ref   = 1;  $max_recipients    = 5;  $mailprog          = '/usr/lib/sendmail -oi -t';  $postmaster        = '';  @referers          = qw(;  @allow_mail_to     = qw(;  @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;

I have this in my cgibin folder.

What am Idoing wrong?

Any help is great.


n/a Points
2014-08-27 2:12 pm

I get a confirmation page but do not get email?

$DEBUGGING         = 1;  $emulate_matts_code= 0;  $secure            = 1;  $allow_empty_ref   = 1;  $max_recipients    = 5;  $mailprog          = '/usr/lib/sendmail -oi -t';  $postmaster        = '';  @referers          = qw(;  @allow_mail_to     = qw(;  @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;

I have this in my cgibin folder.

What am Idoing wrong?

Any help is great.


n/a Points
2014-08-12 10:15 pm
Your is great but when it is used the from email is Why is this? How do I fix this? It must be a setting in your form mail program Please email me and let me know at thanks
11,186 Points
2014-08-27 11:52 am
To do so, you may simply set a field within your form that looks like this:

<input type="text" name="email">

By creating this input field, a user will be able to specify their email address, and the "From" address will be set to their input.
9,968 Points
2014-01-17 7:55 pm
Hello Tom,

If you're trying to use utf-8 with, the only thing you need to change in the script is just the following line:

$charset = 'utf-8';

In your HTML form itself, you need to specify the charset to also be UTF-8 so that when a web-browser loads the page it already knows that charset should be used for any data submitted from the page.

Just stick this bit of code between your <head> and </head> tags:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

That should do the trick. I went ahead and tested this to verify and it went from sending my email account HTML encoded characters like &#1053; to actually displaying the correct UTF-8 character Н which in that case was a Cyrillic capital H.

If you're still having any issues and you're hosted on our servers, please let us know your domain name either here publicly or by emailing so we can take a closer look at all your code, and to look for any errors on the server.

- Jacob
2014-01-17 1:36 pm
It's not working in my case. Everything is working smoothly, I can send e-mails but utf-8 encoding doesn't work. I've changed the following (no result):
$charset = 'utf-8';

my $cs = CGI::NMS::Charset->new('utf-8');
$self->{CFG} = {

emulate_matts_code => 0,
secure => 1,
locale => '',
charset => 'utf-8',
30,400 Points
2012-10-16 1:58 pm
Hello Mikexzhou,

Thank you for your question regarding using UTF-8 with formmail.

You can update this setting by editing the the line of code in file pertaining to:
$charset = 'iso-8859-1';

To update it, change 'iso-8859-1' to:

If you have any further questions, feel free to post them below.
Thank you,

2012-10-16 1:32 pm
Do you have any instruction to setup to support UTF-8? (Asia characters


Mike Zhou

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

37 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!