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 wrote a ste-by-step guide to installing and configuring FormMail: If you missed our previous article, please see the How Contact Forms Work tutorial.

  1. Download the "compat" version of the NMS FormMail script.
  2. Un-zip the downloaded file and upload the FormMail.pl script to your cgi-bin folder in your public_html folder.
  3. 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.
  4. 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.
  5. 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.yourdomain.com/cgi-bin/FormMail.pl" method="post">
    
  6. 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="you@your.domain,me@your.domain" />
    

    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.

  7. Finally in order for FormMail to work you must set the permissions on the FormMail.pl to 755.  This can be completed within your File Manager as well by right clicking on the file and selecting "change permissions." For more information on this course please visit Adding Contact Forms.

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."

Continued Education in Course 202: Adding Contact Forms
You are viewing Section 3: Creating a Contact Form with FormMail
Section 2: How Contact Forms Work
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Datepicker or equivelant and FormMail
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-07-30 10:25 am
I am still learning the system. Just under too much pressure to read slowly and understand.
Staff
9,260 Points
2014-08-11 4:19 pm
Hello Gerard,

Thank you for contacting us. We are happy to help you setup your FormMail, is there a step you are having trouble with?

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

-John-Paul
n/a Points
2014-08-15 6:17 am

Hi John,

 

I would like to try this to our company website but I don't understand well how to follow the instructions correctly.

Maybe it can help if you put also the certain line in #3 and #4 instructions to go to, to make it easier.

Thanks!

Armand

 

Staff
9,260 Points
2014-08-15 9:11 am
Hello Armand,

Thank you for your suggestion. I have created a ticket for our Support Center team, and we will be reviewing the article.

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

-John-Paul
n/a Points
2014-09-15 6:53 pm

I'm fine until step 5, I have no idea where to add the code to. This is the first time I've been into the cPanel and really feel confused now. I'd really like to understand this a bit better. I've been trying to research this for about a week and just found your site. Thank you

Staff
17,172 Points
2014-09-15 7:17 pm
Hello Patricia,

Sorry that you're feeling confused. Websites are basically files on a server. In order to obtain the data for email that you want to automatically send, you need a web page that is referencing the form. The CGI-BIN is a folder on your server - this is where the script that you obtained from the zip file will need to be saved. You can use the cPanel File manager for an easy way to manipulate files on your server.

If you need more detailed help with creating the form on your website, follow these tutorials and they'll help you understand that portion of it: Adding Contact Forms to your website.

Hope that helps! If you have any further questions please let us know.

Regards,
Arnel C.
n/a Points
2014-09-15 8:55 pm

Thanks for such a quick response, that was awesome! I'm confused as to where exactly I'm to put steps 5 and 6 of the Creating a Contact Form with FormMail tut. Does it go in the Perl doc or in my Dreamweaver Contact page, where I created the html. Does it go in the head or body? Thanks again.

 

Staff
17,172 Points
2014-09-15 9:21 pm
Hello Patricia,

The code goes into your web page - where ever your form code located. The PERL script changes are edited directly in the PL file that saved in your CGI-BIN folder. The web page is where ever you're displaying the form where your visitors have to click and fill out the fields in order for the form mail to be sent. If you're still confused, please let me know.


Regards,
Arnel Cl
n/a Points
2014-09-28 4:29 pm

I have 2 problems I'm trying to fix.

1) I got the form to work but under the subject line it says "Below is the result of your feedback form.  It was submitted by () on Sunday, September 28, 2014 at 15:51:16"

Shouldn't the () show the person's name and/or email who submitted it?  It makes no sense for it to be empty.

 

2) the email I get is from "nobody@ecbiz(my server).inmotionhosting.com"  This really looks like spam.  Is there a way to have it come from a name I choose?

I'm not a programmer but if you tell me what to change in the perl script I can do that.

Sorry if this is a duplicate.  The captcha said it didn't work although I thought it did.

Staff
9,260 Points
2014-09-29 11:26 am
Hello liz,

Thank you for your question. 1) I looked through the README file included with the formail script, and it says the From should be pulled from the form. Meaning if they fill out the "from" field, it should be included.

2) We are happy to help, but will need some additional information to answer this section. Is this the email you get when you fill out the form? or is this sent to you notifying you that someone else has filled out the form? Can you provide a link to the form?

Feel free to post any additional questions below.

Thank you,
John-Paul
n/a Points
2014-09-29 12:42 pm

I filled out the form myself and submitted it and this is what I received.

 

Thanks,

Liz

Staff
17,172 Points
2014-09-29 1:51 pm
Hello Liz,

Sorry for the problem. Can you provide some details on what you received? We don't see anything in your reply.

Regards,
Arnel C.
n/a Points
2014-09-29 3:58 pm

Here is the link to my sample form http://www.refugeerelief.org/formtest.html

What I received is:

 

nobody@ecbiz158.inmotionhosting.com

Volunteer Form

Below is the result of your feedback form.  It was submitted by

() on Monday, September 29, 2014 at 15:56:52---------------------------------------------------------------------------name: lizanimal: cat---------------------------------------------------------------------------

Staff
19,241 Points
2014-09-29 5:45 pm
Hello Liz,

I have set up a test form on my own server with the FormMail and have run a few tests. The 'nobody@' email address appears when the email section of the form is left blank. This is the same for the () that appears. This means that the name field was seen to be empty.

When I put information in those fields, I receive the email and it has the content that was inserted in place of the default information (nobody@ and () ).

Kindest Regards,
Scott M
n/a Points
2014-09-29 6:21 pm

i just filled out our real form (not our previous test form)  which has the same action script http://refugeerelief.org/contact.shtml  and I got the same thing

I entered my name in the name field and my email in the email field.  The result is the same.

The email is still coming "nobody@ecbiz158.inmotionhosting.com," the header is still correct which says "volunteer form" but the first line of text still says ays "Below is the result of your feedback form.  It was submitted by () on Monday, September 29, 2014 at 18:16:03"  Underneath that it does give my name and email where I filled out the form fields but I want to change the "from nobody@ecbiz158.inmotionhosting.com" and the "It was submitted by ()"

I don't know why you are getting different results from me.  I am using Apple mail on a desktop computer to receive my mail.

Liz

Staff
17,172 Points
2014-09-29 7:01 pm
Hello Liz,

Sorry about the confusion with the form. Scott and I have both looked at this. I discovered the cause for this as a security setting on shared servers. This security setting basically forces the "nobody@servername.com" to appear when mail is sent without specifying a server and server - this happens with the formmail script. Luckily, you can easily fix this. Here's the section in the FormMail readme file on using SMTP settings (that stop the nobody thing from happening):

If your web server lacks a sendmail binary, you can
use an SMTP relay instead, by setting $mailprog like
this:

$mailprog = 'SMTP:mailhost.your.domain';

You will need to replace mailhost.your.domain with
the name or IP address of an SMTP server configured
to relay mail for the web server.

Your system administrator or hosting provider should
be able to tell you either the path to sendmail on the
web server or the name of a host that will act as an
SMTP relay for the web server.

You can find your OUTBOUND SMTP settings by reviewing this article: How to find my email settings.

Modify your form and then with those settings, then the Sender should be set to the Postmaster setting in your script. If you continue to have problems with it, please let us know.

Sorry again for the headaches with the form. The setting for NOBODY is forced in order to help put a stop to SPAM issues on our servers. Forcing a sender of NOBODY when SMTP settings and sender are not verified allows us to track where the email is coming from and put a stop to illicit spam scripts that are sometimes forced on unaware account owners.

Kindest regards,
Arnel C.
n/a Points
2014-09-29 9:45 pm

Thank you for figuring this out.  Unfortunately, not being a programmer, I am still unclear on what to do. I'm told by tech support that I can't use sendmail and they suggested using a php script.  Regarding your fix for not having sendmail, where exactly do I put $mailprog = 'SMTP:mailhost.your.domain. Somewhere on the FormMail.pl file?

Thanks,Liz

Staff
17,172 Points
2014-09-30 12:24 pm
Hello Liz,

Sorry for the confusion. The Formmail.pl file is a PERL script, but it also a simple text file that you can edit using a text editor such as the one available to you through the cPanel (checkout: Using the File Manager Code Editor).

You would look for this line:

$mailprog = 'SMTP:mailhost.your.domain';

And replace the SMTP:mailhost.your.domain with your SMTP settings. So it would look like this:

$mailprog = 'SMTP:mail.refugeerelief.com';


I hope that helps to clarify it for you! You don't need to be a programmer to make this kind of change. Let us know if you require any further assistance.

Regards,
Arnel C.




n/a Points
2014-09-30 8:07 pm

I could not find a line that says $mailprog = 'SMTP:mailhost.your.domain';

In searching for anything with $mailprog all I found is what I've pasted below.  Theses are in different sections of the file.

The only references I could find to  are below.  I can email you the whole formmail if you want.

Liz

use vars qw(

  $DEBUGGING $emulate_matts_code $secure %more_config

  $allow_empty_ref $max_recipients $mailprog @referers

  @allow_mail_to @recipients %recipient_alias

  @valid_ENV $date_fmt $style $send_confirmation_mail

  $confirmation_text $locale $charset $no_content

  $double_spacing $wrap_text $wrap_style $postmaster 

  $address_style

);

 

 

 $mailprog          = '/usr/lib/sendmail -oi -t';

 

sub new {

  my ($pkg, $mailprog) = @_;

 

  return bless { Mailprog => $mailprog }, $pkg;

}

 

 mailprog               => $mailprog,

Staff
8,910 Points
2014-09-30 8:11 pm
This line is indeed within the FormMail script that is linked to in this article and can be found on line 1777 by default.
n/a Points
2014-09-30 9:03 pm

I didn't find anything on 1777 but on 1780 I found the following

An SMTP relay can be specified instead of a sendmail compatible mail program,using the prefix C<SMTP:>, for example:'mailprog' => 'SMTP:mailhost.your.domain',Default: C<'/usr/lib/sendmail -oi -t'>

and I changed the 'mailprog' => 'SMTP:mailhost.your.domain', to 

'mailprog' => 'SMTP:mail.refugeerelief.org',  but I think I was just changing an example and not the code since there was no $ in front of it.  It didn't do anything.

Staff
8,910 Points
2014-09-30 9:15 pm
I apologize, I made an error in my comment. Simply replace:

$mailprog = '/usr/lib/sendmail -oi -t';


With:

$mailprog = 'SMTP:mail.refugeerelief.com';

n/a Points
2014-09-30 9:24 pm

I commented out line 45 that said

$mailprog          = '/usr/lib/sendmail -oi -t';

and replaced it with 

p class="code_block">$mailprog = 'SMTP:mail.refugeerelief.org';

and got an error message

Error 500 - Internal Server Error

An error was encountered while processing your request. Typically this is a temporary condition. Please contact the web site owner for further assistance.

Staff
8,910 Points
2014-10-01 9:32 am
You may have seen my comment before the formatting was edited just a few seconds after it was posted. Please see the comment as it currently is as it contains the correct code without the formatting error.
n/a Points
2014-10-01 2:20 pm

Ok, I put in the corrected code, uploaded it twice.  I get the same "from nobody" results and the same "submitted by () as before.  I even checked it in 2 different browsers that didn't have the form in its cache.

Staff
17,172 Points
2014-10-01 3:41 pm
Hello Liz,

I'm probably going to spending some time updating our documentation because of your request, but that's a good thing. Sorry for the delay in getting this fixed the way you wanted. Here's what needs to be changed.

In your FORMMAIL.PL file, open the file to edit it and then look for the following line:

return $email;

If you're using the code editor, it should be line 2720 (or around there).

We changed this in your actual form online and it works. I changed it to "IAMTHEFORM" and tested it - you should see the test emails (pardon my silliness in the form). When you change it, make the line look like this:

return 'IAMTHEFORM';

Please try this out and replace the '$email' with your FROM value that you wish to use. Apologies again for the delay in getting this straight. Let us know if you continue to have any problems.

Regards,
Arnel C.
n/a Points
2014-10-01 5:09 pm

I changed  return $email; on line 2720  to  return Refugee Relief Form; and got an error message as shown below.  I've changed it back for now so the form will work while I'm working on it.  I  didn't get any "IAMTHEFORM" emails.

By the way, since I changed $mailprog = '/usr/lib/sendmail -oi -t'; 

to

$mailprog = 'SMTP:mail.refugeerelief.com';

the form hangs so long before sending that people might think it is broken.

 

Error 500 - Internal Server Error

An error was encountered while processing your request. Typically this is a temporary condition. Please contact the web site owner for further assistance.

Staff
17,172 Points
2014-10-01 5:20 pm
Liz,

Sorry you're getting the error. I was working directly with your form and I never got any of those errors. The code is very specific. Make sure that you're putting single quotes around the value you change and then end it with a semi-colon. If you don't do that, you will get the 500 error.

I changed the value to "The Form" for now. Check it out and see if it's working. If you're still seeing it fail, please let me know immediately.

Regards,
Arnel C.
n/a Points
2014-10-01 5:20 pm

Does

 return Refugee Relief Form;

have to have quotes? If so, single or double?  Please send how it should looke

Staff
17,172 Points
2014-10-01 5:22 pm
Hi Liz,

No problem - I made sure that my example code in the comments above was technically correct using single quotes and a semicolon. I also changed in the form so that you could see it. You simply have to change the text in between the single quotes.

Kindest regards,
Arnel C.
n/a Points
2014-10-01 5:31 pm

Fabulous!  It now says from "Refugee Relief Volunteer Form"  in the from part of the email. Below that though it still says "...submitted by ()..."  Is there a way to change that?  Also for the lag time if there is no way to fix that I'll put a note on the page that the form might take a little while to send.

Staff
17,172 Points
2014-10-01 5:37 pm
Hi Liz,

Believe it or not, we've actually been looking at that particular part of the form - we're still looking for a way to change to that. This form wasn't made by us, unfortunately. As soon as I find a solution for it, I'll email you directly. As for the lag, it has to do with the mail being delivered on the server, so it may take a few minutes depending on the server load. We do appreciate your patience on the issue.

Regards,
Arnel C.
n/a Points
2014-10-01 5:45 pm

I understand.  Thank you for all your help and I look forward to getting the fix for that part of the form when you get one.  The form is much better now and not as likely to end up in junk mail.

Staff
17,172 Points
2014-10-01 6:30 pm
Hello Liz,

I'll add this reply here for anyone reading through this issue in the future (and I'll send you an email as promised).

I found the "submitted by" text within the formmail.pl script. It's on line 2841. I replaced the code with text. You can open the file and take a look. Currently, any form will read, "submitted by the webmaster of RefugeeRelief.org".

Check it out and let us know if you have any further problems!

Regards,
Arnel C.
n/a Points
2014-10-01 8:45 pm

Unfortunately now I get an error message.  I'm going to put it back the way it was so the form will work until we fix it.

Error: Bad or Missing Recipient

There was no recipient or an invalid recipient specified in the data sent to FormMail. Please make sure you have filled in the recipient form field with an e-mail address that has been configured in @recipients or @allow_mail_to. More information on filling in recipient/allow_mail_to form fields and variables can be found in the README file.

The recipient was: [ test@refugeerelief.org ]

FormMail © 2001-2003 London Perl Mongers

n/a Points
2014-10-01 8:56 pm

I sent in a previous message that the form now gives me an error message as seen below. I put that last line back the way it was but still getting the error message. Did you change something else on your end?  I have to get the form working at least to where it was before.

Thanks,Liz

Error: Bad or Missing Recipient

There was no recipient or an invalid recipient specified in the data sent to FormMail. Please make sure you have filled in the recipient form field with an e-mail address that has been configured in @recipients or @allow_mail_to. More information on filling in recipient/allow_mail_to form fields and variables can be found in the README file.

The recipient was: [ test@refugeerelief.org ]

Staff
17,172 Points
2014-10-01 10:06 pm
Liz,

Sorry about this craziness. I looked at the formmail.pl script and the only thing I had left in place was my test email address in one of the fields. Apparently, leaving that email address in the field caused the form to choke. As soon as I removed it, I could see it working instead of giving you the error. I diagnosed it by looking at what the form was sending as a recipient (test@refugeerelief.org) and what the script was expecting. It should be okay now. You can try making that change to the text as per the above. I'll make sure to double-check this tomorrow when I get into the office to make sure everything's okay. Have a good evening!

Regards,
Arnel C.
n/a Points
2014-10-02 2:04 am

Thanks for fixing it. I put "Refugee Relief" back where you had it and it works perfectly now.  I will change the @allow_mail_to  back to the real email instead of the test email that goes to me, so if you are going to do anything else to the form please let me know first so I can change it back to test. I don't see anything else that needs to be done though, it works fine now.

I hope that the instructions on inmotion hosting's website on creating a formmail will be updated to include the changes we've made and will state approximately what line these changes are on so when I or someone else need to make a new form on another website it will be straightforward.

I have one more question. I got a spam email that used the form.  When I signed up for hosting I did not include that extra charge for what I think was McAfee on the email account.  Would adding that help us not get spam sent through the form?

Liz

Staff
19,241 Points
2014-10-02 8:31 am
Hello Liz,

We are happy it is now working for you. Arnel and I had fun crawling through the code and testing different things. (Well, I had fun. I'm not sure about Arnel.) We will change the article to tell how to make the changes, but we hope to be able to modify the code where it is done more easily and not have to crawl through all the code, even if we give the approximate line number. We didn't write the original so we have to make sure any changes we make do not break anything else.

As for the McAfee, adding that will have no effect on the form. Forms with no human verification method such as Captcha (and even then, no guarantee) are often hit by spam bots and automatically filled out. We even get them daily in our questions and comments. It is a constant cat and mouse game and although we can put enough checks in place to practically eliminate all bots, it makes things more difficult for the customers like yourself. So we deal with them as they come for the most part.

Adding a captcha to the form would not be a bad idea, but we do not have any code for that in place for the formmail. Keep checking back as we do want to create a tool for customers that creates a very nice custom form with optional human verification in it.

Kindest Regards,
Scott M

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

39 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

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: support@InMotionHosting.com
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!