homepage Welcome to WebmasterWorld Guest from 54.197.183.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Using Sendmail from a generated page.
...what do I need to change to make it work?
GranoSalis

5+ Year Member



 
Msg#: 4322 posted 10:40 am on Dec 19, 2005 (gmt 0)

Disclaimer: I am not very cgi-literate, for example the specific terms or names for aspects of the script. And other things. So please forgive and correct me if/when I am wrong.

Is there something about the Sendmail program (?) that needs to be changed when calling (?) it from a page which you have already generated using another script? For example the path to it?

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.

Any clues?
Thanks

 

carfo

5+ Year Member



 
Msg#: 4322 posted 4:11 am on Dec 20, 2005 (gmt 0)

Not entirely sure what you mean by static vs generated pages in this context here and how that could relate to sendmail. Inway, could be a multitude of reasosn why a cgi script fails to send emails correctly. I'd suggest taking out the portion that deal with the sending of the mail and running that in another script from the command line to test. Also, make sure you invoke sendmail with the full path to it. Check too that your sendmail is configured to accept mail from the domain you're trying to send. Hope this is of some use to you.

GranoSalis

5+ Year Member



 
Msg#: 4322 posted 10:19 am on Dec 22, 2005 (gmt 0)

I warned you... ;-)

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.

Confused?

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!

GranoSalis

5+ Year Member



 
Msg#: 4322 posted 10:27 am on Dec 22, 2005 (gmt 0)

carfo, what is the full path to sendmail? That might 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?

Thanks

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4322 posted 9:05 pm on Dec 22, 2005 (gmt 0)

The path to sendmail depends on the server.

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 "content-type:text/html\n\n";
print "path to sendmail: $mailprog <br>\n";
print "To Email:$email<br>\n";
print "From email: $from <br>\n";
exit 0;

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.

bennymack

5+ Year Member



 
Msg#: 4322 posted 1:14 am on Dec 23, 2005 (gmt 0)

You might want to look into Net::SMTP. It's more robust, secure, and cross-platform than executing sendmail directly...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved