"Method Not Allowed
The requested method POST is not allowed for the URL /cgi-bin/FormMail.pl."
I've checked the code at the start of my form and that on the FormMail.pl script and they match what I've used on a previous (successful site). Has anyone any suggestions what's wrong?
Iain
Keep in mind this probably has nothing to do with perl and is not really a CGI issue either, more than likely it is a server problem.
Have you tried changing the name of the script to something completely different? mailhandler.cgi for example.
If that doesn't work and they are actually restricting POST requests to all perl scripts then don't even bother contacting them, switch hosts.
I'm beginning to think it is the server, however I have used a similar form with them in the past without a problem. I tried changing POST to GET and got the following:
Forbidden
You don't have permission to access /cgi-bin/mailhandler.cgi on this server.
Iain
<form method="GET" action="http://www.example.co.uk/cgi-bin/mailhandler.cgi">
<input type="hidden" name="recipient" value="root@example.co.uk">
<input type="hidden" name="subject" value="Enquiry">
<input type="hidden" name="httpreferer" value="http://www.example.co.uk/enquiry.html">
Does this all seem right
[edited by: phranque at 3:18 pm (utc) on April 30, 2008]
[edit reason] examplified urls [/edit]
"Method Not Allowed
The requested method POST is not allowed for the URL /cgi-bin/FormMail.pl."
That's a server error. Also he said that he tried both GET and POST.
The fact that you've used the script before and it worked, and that your associate is now having the same problem, clinches that it's something your host has done. Again most likely an amateur attempt at security.
It sounds like this is shared hosting correct? You don't have a dedicated server? Shared hosting is one of the most competitive industries on the internet, monthly prices are down to around $5-$10 (for a quality host mind you), don't waste time with a host gives you problems.
Is the server sensitive? (e.g.- maybe lower-case "formmail.pl" will work)...
Simple test to know if the server will execute a perl script... put a basic "hello world" script in the cgi-bin where your non functioning script is -- if it will execute one script, it should run any... that will nail down the "is it the script or the server?" question.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><BODY><H1>Hello World</H1></BODY></HTML>\n";
If "Hello World" prints, it's your script or one of the parameters in your script.
If it does not print, it's the server or the permissions on the cgi-bin.
what are the ownership and permissions on the file?
i would try renaming the script to formmail.cgi in case it doesn't let you use .pl files as cgi scripts.
it can't hurt.
it looks like you may have tried this but make sure to change the action attribute in the form tag to match the new script name.
it's also possible it doesn't like you directly accessing the cgi-bin directory - try using just ...action="formmail.cgi"... without domain and path information and see if it finds the script in cgi-bin.
[edited by: phranque at 10:19 am (utc) on May 3, 2008]
I hate to beat a dead horse but:
"Method Not Allowed
The requested method POST is not allowed for the URL /cgi-bin/FormMail.pl."
and also
You don't have permission to access /cgi-bin/mailhandler.cgi on this server.
There is absolutely nothing you can do wrong with a perl script that will cause the first error on a correctly configured server.
The second error you could only re-create by CHOWNing the script which is impossible to do via either FTP or the control panel on shared hosting.
Is FormMail.pl in the cgi-bin ?
The OP mentioned that it was earlier in this thread and that his host told him to put it there.
Is the server sensitive? (e.g.- maybe lower-case "formmail.pl" will work)...
He tried changing the filename to an all lowercase name already, see above.
Simple test to know if the server will execute a perl script...
Again see above, and besides, the errors have nothing to do with whether or not perl can run.
I don't mean to nitpick (I know you're just trying to help) but I'd like to see the OP find a solution and that's not going to happen until his host either gives him a meaningful reply or changes the server config.
2. Look at error log from webserver
3. Check if correct name of program is being used. It must be in correct case.
4. Don't use <input type="hidden" name="recipient" - anybody will be able to replace this and send mail to anyone, this is frequently used by spammers. Matt scripts archive is very bad place to get reliable programs. Put recipient directly into program.
Please contact the server administrator, webmaster@chippendale.co.uk 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."
Does this change things. Also Chorny, what would you suggest instead of "<input type="hidden" name="recipient""
If the permissions are correct then you can get more information about the script error by putting the following near the top of the script:
use CGI::Carp qw(fatalsToBrowser);
Any idea?
[edited by: phranque at 3:29 am (utc) on May 17, 2008]
[edit reason] examplified ip and url [/edit]
So the permissions must be 755. (You can do that in cPanel.)
You must use POST, not GET.
Name the script to some name that does NOT have "form" or "mail" anywhere in the name. Some hosts will prohibit any script with a name like that.
For "action=", try a local path instead of absolute (eliminate the http: //...).
The fact that the host tech changed server settings and now you're getting a different error points to a server config issue rather than something wrong with the script.
In response to chorny's comment, if you're using Matt's original FormMail.pl program, switch to the NMS FormMail version available at SourceForge.
[edited by: SteveWh at 1:19 pm (utc) on May 16, 2008]