Unexpected script termination with mail(), no help from host
Moderator: General Moderators
-
GreatBigBore
- Forum Newbie
- Posts: 4
- Joined: Tue Aug 11, 2009 11:55 am
Unexpected script termination with mail(), no help from host
I have inherited a PHP script that occasionally terminates unexpectedly. The technical support people at the host are no help, and I'm not getting anything useful from the error logs. Most of the time the script runs just fine. When it does fail, it almost always fails when it calls the mail() function. I don't mean that mail() is returning FALSE. I mean that the script runs up to the mail() function and then just completely dies. I've tried a try/catch block, but nothing is caught; the script still just dies silently. Anyone have any ideas on how to approach this problem? How to catch this weirdly catastrophic failure? What might cause mail() to fail in this way? I've already double-checked that it's not the particular email address or the content; I can restart the script and it will send mail just fine to the same person that it failed for on the previous run. Also, the script is too complex to post here, and I really don't think that would help anyway. I'm just looking for ideas on how to approach a failure that occurs on a perfectly normal call to the mail() function. --Rob
Re: Unexpected script termination with mail(), no help from host
Does it run for, say, 30 seconds before dying? Are you looking at the PHP logs or the server logs? (Check both)
-
GreatBigBore
- Forum Newbie
- Posts: 4
- Joined: Tue Aug 11, 2009 11:55 am
Re: Unexpected script termination with mail(), no help from host
Thanks, but I already checked that. The duration varies from ten seconds to 30 minutes (I have no idea how the server allows my script to run for that long, but it really does). No discernible pattern. I've also checked memory usage, and I've seen it fail using 4MB as well as working just fine using 12MB. Unfortunately, the host doesn't allow me access to either the PHP logs or the server logs--for "technical reasons". I'm still working on that angle, begging them to let me see the logs, but I'm up against a wall there. At this point I have more hope that this community will help me find an answer than the useless drones at the hosting company.
Re: Unexpected script termination with mail(), no help from host
I'm thinking a problem with sendmail (or whatever program it is that actually sends the mail). Bad configuration or something. Has it always been like this or is it a recent thing? Anything changed on the server that you know of?
-
GreatBigBore
- Forum Newbie
- Posts: 4
- Joined: Tue Aug 11, 2009 11:55 am
Re: Unexpected script termination with mail(), no help from host
Unfortunately I have no visibility into the server; it's one of these host-in-the-box companies that trains their technical support people to get customers off the phone rather than actually helping them. Don't know whether it's a recent failure; I inherited the script recently, but I don't know how long this problem had been going on before it came to me. I'm just looking for ideas on how to approach the problem, how to catch it, how to detect it, how to get around it, that sort of thing.
Re: Unexpected script termination with mail(), no help from host
Well, you've gone as far as you can with PHP, right? You know that the code dies during the call to mail() so there's nothing you can do after it; before it, take a look at a variety of variables and see if there's any pattern.
Outside of PHP it'd be logs... unless you can get the code to fail like that on another machine, one over which you have more control.
Outside of PHP it'd be logs... unless you can get the code to fail like that on another machine, one over which you have more control.
-
GreatBigBore
- Forum Newbie
- Posts: 4
- Joined: Tue Aug 11, 2009 11:55 am
Re: Unexpected script termination with mail(), no help from host
I'm not convinced that I've gone as far as I can with PHP. I'm still hoping that someone will look at this thread and say, "Oh yeah, I heard about a problem like that once and here's some info..." or "Here is a page that shows a bunch of cool under-the-hood info for the PHP mail() function." Or "Here's a way to catch and diagnose unexpected script terminations." That sort of thing. Thanks for the insights. --Rob