Forum Moderators: coopster & phranque

Message Too Old, No Replies

FormMail.pl tries to save rather than send?

FormMail.pl unwanted save

         

HaRM5

4:31 am on Jul 10, 2008 (gmt 0)

10+ Year Member



Hope someone can help.
The booking form on my site tries to save the form data rather than send the data email to the specified recipient, and does not activate the 'Confirmation page'
Any help would be greatly appreciated

phranque

5:37 am on Jul 10, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], HaRM5!

have you looked for clues in the server error log?
have you checked to make sure sendmail is installed on your server and is in the location specified in the script?

rocknbil

8:23 am on Jul 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tries to save the form data rather than send the data email to the specified recipient,

So you submit the form and your browser pops up a dialogue box, asking you to save the file, is this correct? I'd also look into the mail configuration. If the script errors attempting to mail, it may error and try to print the error to SDOUT before the content-type headers are printed.

Normally, printing ANYTHING out from a perl script called by a browser before the headers are printed will cause a server 500 error. In some server configurations, it won't error - sometimes it will do just as you say, assume the content-type is unknown and prompt a dialogue box.

HaRM5

10:38 pm on Jul 10, 2008 (gmt 0)

10+ Year Member



Thanks, yes it comes up with a dialog box. I've also noticed that the data which it saves has no CSS to its format. Is this a clue?

P.s Thanks heaps for responding, very much appreciated....

rocknbil

5:10 pm on Jul 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, what data does it save? That might be a clue.

It still sounds like phranque hit it, it's most likely the mail program is incorrectly configured, not responding, or throwing an error. Follow this:

1. Any perl script MUST print a content type header before printing anything to the browser or it will throw a 500 error.

2. Most mailers execute in this order:

a. Read/parse input data (and hopefully cleanse)
b. Compose and SEND mail
c. return response to browser.

Usually they won't output content-type headers until step C. If the mail program prints out an error in step b., it's going to error. Combine this with an incorrect error handling on your server, you get an invalid content-type which prompts a download box.

Try this: At the top of your script you should find

#!/usr/bin/perl

Right after that put a header so it prints out before the program does ANYTHING. It should look like this:

#!/usr/bin/perl
print "content-type:text/html\n\n";

The two new lines \n\n are critical.

Now run the script, if you see something new at the top, like

/usr/sbin/sendmail: no such file or directory

you've found your answer.

If not, I'm chasing the wrong bug. :-(

HaRM5

10:30 pm on Jul 14, 2008 (gmt 0)

10+ Year Member



Thanks heaps, give me a sec and I'll try it out

HaRM5

4:41 am on Jul 16, 2008 (gmt 0)

10+ Year Member



Thanks all is working well,

Thankyou for your time and assistance.
Very very much appreciated.

phranque

6:34 am on Jul 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



and the problem was...?