Welcome to WebmasterWorld Guest from 188.8.131.52
The same program works (i.e. it sends me the email and I recieve it) from another, static (?) page (I tested it).
The path to the script to be called (in the action="" attribute of the form which calls the script) is defined absolutely, so there shouldn't be a problem there.
Finally, the script also generates a new 'Thank you' page, which works even when the email doesn't.
OK - I've got a standard html page "PAGE1" (I called it a 'static' page) which, when a form is submitted, calls a cgi script "SCRIPT1" which creates a new page "PAGE2".
On this new page "PAGE2" (I called it a 'generated' page) there is another form, which, when submitted, calls another cgi script "SCRIPT2" which is meant to create a new page "PAGE3" and send an email.
Anyway, the email never arrives - BUT the new new page "PAGE3" does appear.
BUT the unsuccessful script "SCRIPT2" and the form which calls it are not faulty in and of themselves:
I put the same form - the one which calls SCRIPT2 - on a normal html page, and both parts of the script worked - i.e. the email and the new page "PAGE3".
Thus, there are no typos in the form or script "SCRIPT2" (e.g. wrong email address!)
The path to SCRIPT2 is defined absolutely (and is obviously correct anyway as part of SCRIPT2 works always).
Basically, I don't know where to go from there.
There's no problem with the script itself, and as it works perfectly when it is called from a normal html page (as opposed to a page which has already been created by another script), I figured that might have something to do with it.
I also figured that it might have something to do with the path to Sendmail. But I may be completely off.
Hope you guys can help!
At the moment I am using "/usr/sbin/sendmail" ("/usr/lib/sendmail" also works).
It does work from any other page (other than this one which has already been created by another script), so sendmail does accept mail from my domain - but how would I go about 'configuring' sendmail?
Grano the first thing one has to learn with CGI scripting is to figger out where it's breaking and you can do that by interrupting the script with printouts and an exit at any point. So if your second script is dying, try this:
Form submits to script, and in script you have
1. read/parse data
2. Perform functions (in this case mail)
3. print response to browser.
So, the first thing you do is just before it attempts to email, add this to the script:
print "path to sendmail: $mailprog <br>\n";
print "To Email:$email<br>\n";
print "From email: $from <br>\n";
You will get a server error if you do not print the content-type header with two newlines. Add a print line for every variable you think might be going wonky. This will print out the variables to your browser and the exit line will stop the script.
Most likely sendmail is not getting a correct to or from email and is dying.
If you have access to mail logs, this would be very helpful as you could hit the script then look at the logs and see if there's an actual error, but many domains only offer web access logs.
Give it a shot, happy debugging and welcome aboard.