New Formmail.pl Walkthrough

Discuss forms and the best CGIs for handling visitors info from your web site

Moderators: Ilbin, Chuck, Vanessa

New Formmail.pl Walkthrough

Postby brandonf on Wed Aug 29, 2007 10:30 pm

Here is a walkthrough 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.

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

2) 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. The first is the @referrers 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) Next you will want to modify the next line down, the @allow_mail_to line. 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 @referrers 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 FormMail.pl script inside the cgi-bin.

Code: Select all
<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:

Code: Select all
<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

Code: Select all
<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.

Code: Select all
<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. If you do not include this they will be directed to a very generic looking page created by the FormMail script.

7) 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 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 FormMail.pl 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 FormMail.pl 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@inmotionhosting.com.
brandonf
InMotion Staff
 
Posts: 1
Joined: Wed Aug 29, 2007 8:34 pm

Will this mailform work with PHP script?

Postby Skywalker on Sat Dec 29, 2007 8:32 am

Hi,

I am running a PHP script social network web site. Will this CGI mail form work or I need a PHP mailform? Thanks.

Skywalker
Skywalker
Forum User
 
Posts: 22
Joined: Tue Oct 16, 2007 4:50 am

Re: Will this mailform work with PHP script?

Postby trose on Fri Oct 01, 2010 10:08 pm

Skywalker wrote:Hi,

I am running a PHP script social network web site. Will this CGI mail form work or I need a PHP mailform? Thanks.

Skywalker


Hey I was wondering the same thing... did you find out?
I feel like PHP would work a lot better.
trose
Forum User
 
Posts: 2
Joined: Fri Oct 01, 2010 10:06 pm

Re: New Formmail.pl Walkthrough

Postby trose on Sun Oct 10, 2010 10:58 pm

ever find out??
trose
Forum User
 
Posts: 2
Joined: Fri Oct 01, 2010 10:06 pm

Re: New Formmail.pl Walkthrough

Postby jdmajor on Wed Jun 15, 2011 3:00 am

This was posted in 2007, it is now 2011 and although my formmail.pl and my contact form have worked on a windows server, since I am now using InMotion Hosting, I can't get my forms to work. I have tried contact.shtml form in my cgi-bin directory, and I have tried using contact.html located in my public-html directory, I keep getting errors. I have tried several different paths in my contact form showing where my formmail.pl is located, and I'm about to pull out all of my hair, and it's pretty long and it will hurt. Checking my cpanel "Error Logs" doesn't list any more errors no matter which type they are, so I'm working pretty blind here. Please help.
jdmajor
Forum User
 
Posts: 4
Joined: Wed Jun 15, 2011 12:37 am

Re: New Formmail.pl Walkthrough

Postby bradm on Wed Jun 15, 2011 12:38 pm

Hi jdmajor,

I'm sorry to hear about the form issue that you're having. Please don't pull your hair out, I'm sure we can get this resolved for you!

In order to look into this further, I'll need to know please:
1. The exact error message you are receiving
2. The exact steps I can take to replicate the problem

I look forward to your response, and hopefully we'll get a speedy resolution here for you.

Thanks!

- Brad
bradm
InMotion Staff
 
Posts: 357
Joined: Wed Jan 16, 2008 9:29 pm

Re: New Formmail.pl Walkthrough

Postby jdmajor on Wed Jun 15, 2011 2:10 pm

Hi Brad:

exact error message:
Application Error
An error has occurred in the program
See the web server's error log for details

Part of the problem is that no error logs have been listed in the Error Logs area for any error I am receiving with my forms not working.

I received an email this morning from support@inmotionhosting.com which stated the following:

It appears that the path the the form mail script is currently being called as follows:

/home/jdvisi5/public_html/cgi-bin/formmail.pl

While the actual location would be:

/home/jdvisi5/public_html/cgi-bin/FormMail.pl

I am using the following in my FormMail.pl
#!/usr/bin/perl
as the path to Perl as stated on my cpanel, so it is not clear to me exactly where the above-stated "actual location" would be used, on the FormMail.pl, or in the contact form?

When used in my contact form, nothing happens when I click submit.

When used as the path to perl on my FormMail.pl, the following error (good, the log is working again) occurred:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@jdvisions.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

[Wed Jun 15 08:39:13 2011] [error] [client 99.8.1.236] File does not exist: /home/jdvisi5/public_html/500.shtml

Having the correct path should be included in your FormMail.pl instructions because I am finding out that all servers are configured differently and the correct path should be included as a basic setup specific to inmotionhosting.com.

I would really like to get my simple form to work, or my more complex forms will not work either.
jdmajor
Forum User
 
Posts: 4
Joined: Wed Jun 15, 2011 12:37 am

Re: New Formmail.pl Walkthrough

Postby bradm on Wed Jun 15, 2011 4:34 pm

Thanks for getting back with me.

exact error message:
Application Error
An error has occurred in the program
See the web server's error log for details



I looked at the server's apache logs, and found the following error:

[Wed Jun 15 10:44:25 2011] [error] [client 174.77.92.170] Exim is a Mail Transfer Agent. It is normally called by Mail User Agents,, referer: http://www.jdvisions.com/cgi-bin/co
ntact.shtml
[Wed Jun 15 10:44:25 2011] [error] [client 174.77.92.170] not directly from a shell command line. Options and/or arguments control, referer: http://www.jdvisions.com/cgi-bin/con
tact.shtml
[Wed Jun 15 10:44:25 2011] [error] [client 174.77.92.170] what it does when called. For a list of options, see the Exim documentation., referer: http://www.jdvisions.com/cgi-bin
/contact.shtml
[Wed Jun 15 10:44:25 2011] [error] [client 174.77.92.170] /cgi-bin/FormMail.pl: close sendmail pipe failed, mailprog=[/usr/sbin/sendmail] at (eval 8) line 108., referer: http://www.jdvisions.com/cgi-bin/contact.shtml



... Cleaned up, it looks more like:

Exim is a Mail Transfer Agent. It is normally called by Mail User Agents, not directly from a shell command line. Options and/or arguments control what it does when called. For a list of options, see the Exim documentation.

/cgi-bin/FormMail.pl: close sendmail pipe failed, mailprog=[/usr/sbin/sendmail] at (eval 8) line 108.



Following the lead from the line, Options and/or arguments control what it does when called, through debugging I found that this line in your file did not include any arguments:

Code: Select all
$mailprog          = '/usr/sbin/sendmail';


I compared this with other FormMail scripts that I've got to work in the past, and I see you're missing the -oi and -t arguments:

Code: Select all
$mailprog          = '/usr/lib/sendmail -oi -t';



I made this change, and it seemed to resolve the issue. After submitting your form, I now see a "Thank You" message.

Please test thoroughly, and let me know if everything is working as it should. If you look in your cgi-bin folder, you'll see a backup of the FormMail.pl file, if you need the original version before I made the change.

I hope that helps. As always, we're here 24/7 for support if you have any questions.

Thanks,

- Brad
bradm
InMotion Staff
 
Posts: 357
Joined: Wed Jan 16, 2008 9:29 pm

Re: New Formmail.pl Walkthrough

Postby jdmajor on Wed Jun 15, 2011 6:15 pm

Brad:

I found your post and I had already seen that you had changed my FormMail.pl file. Sorry, I didn't know about inserting the arguments to add to the sendmail program on the FormMail.pl. The form works perfectly now. I tested it and it works fine and brings me to my thank you page. Thanks so much.
jdmajor
Forum User
 
Posts: 4
Joined: Wed Jun 15, 2011 12:37 am

Re: New Formmail.pl Walkthrough

Postby bradm on Wed Jun 15, 2011 6:26 pm

Hi jdmajor,

I'm glad we were able to get this one resolved for you! I'm sure there are quite a few options that FormMail.pl offers, I personally haven't used the script extensively enough to need to explore them all myself.

As always, we're here 24/7 for support. Don't hesitate to contact us at any time if you have further questions, we're here for you!

Thanks,

- Brad
bradm
InMotion Staff
 
Posts: 357
Joined: Wed Jan 16, 2008 9:29 pm

Re: New Formmail.pl Walkthrough

Postby TimS on Tue Nov 01, 2011 11:28 am

Hi logoiweb,

Thanks for posting your fix. It's common to run into case sensitivity issues on a Linux machine. All of our servers run a version of Linux and are case sensitive. Also, file permissions are often the culprit of many issues we field in our tech support department.

If you need further assistance please feel free to contact us.

Thanks!

Tim S
TimS
InMotion Staff
 
Posts: 385
Joined: Mon Sep 12, 2011 11:27 am

Re: New Formmail.pl Walkthrough

Postby Zema0982 on Tue Jan 03, 2012 11:30 am

I have just found your post. I think it is pretty informative and useful. To tell the truth, I have never used it before. You gave me a clear explanation of New Formmail.
Thanks for letting me know this stuff!!!
Zema0982
Forum User
 
Posts: 1
Joined: Tue Jan 03, 2012 11:25 am

Re: New Formmail.pl Walkthrough

Postby TimS on Fri Jan 13, 2012 4:03 pm

Hi latin_sydney,

Thanks for posting your question. I'm more than happy to assist you. FormMail is designed to simply email the results of the form submission to a specified email address. It is not a script designed to handle adding the content to a database. You'd need to custom code a script to append the database with the new information.

While looking into this and seeing if there is a solution already available, I ran accross a free-open source script called formtools. Formtools allows you to store the data you collect in your forms in specific tables so you can view and manipulate the data later. It also gives you the ability to "visualize" the data if you want to see the statistical information.

Here's a link to the formtools website:
http://formtools.org

While I've never installed or used the script (I literally just signed up for a demo account to test it out) but thought it may be a resource for you to look into.

If you need further assistance please feel free to contact us.

Thanks!

Tim S
TimS
InMotion Staff
 
Posts: 385
Joined: Mon Sep 12, 2011 11:27 am

Re: New Formmail.pl Walkthrough

Postby michaella23 on Thu Apr 12, 2012 1:43 pm

I just want to say thank you for the information. It is very valuable for me..newbie here and encountering the same situation.
Thanks and keep up the good work..
michaella23
Forum User
 
Posts: 1
Joined: Thu Apr 12, 2012 1:39 pm

Re: New Formmail.pl Walkthrough

Postby Lawrenceb76 on Tue Oct 02, 2012 11:22 pm

Greetings,

I have a contact.htm page which sends result to my sendresult.php page. The issue, it does everything I expect it to do but emailing me the information.

I was told my my hosting compnay I need to make reference to to the following (<FORM action="/system-cgi/formmail.pl" method="POST">) so the server know which service to use in order for my results to be sent to me. Ok fine, as we can see that code is good if I was putting it in my contact.htm page. How do it get this code to work in my php page? I believe the part I need to use is the ="/system-cgi/formmail.pl" portion. I have not found any support or documentation for this. Can someone help me?
Lawrenceb76
Forum User
 
Posts: 1
Joined: Tue Oct 02, 2012 11:08 pm

Next

Return to Creating and Using Forms

Who is online

Users browsing this forum: No registered users and 0 guests

cron