Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email doesn't get sent

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
Hey,

The page I'm working with is pretty complex. It makes several calls (upwards of 20) out a VPN connection to retrieve data and execute commands on an external source. Each call retrieves data responses. We send several notification emails throughout the process.

I know these theoretical questions are a pain, but I'm hoping someone has had a similar experience and solved it.

So, here's the problem: The last couple of emails sometimes fail to send. It really seems like the end of the page just fails to execute sometimes.

We include a confirmation page, and then send an acknowledgment email and sometimes also a confirmation email.

everything else in the process works but sometimes customers say they never got the confirmation page, it just got stuck loading and never showed it. Other times they get the confirmation page but the emails don't go out.

I've never seen a timeout in the logged errors though. Is there something that could cause the page to just give up? I'm suspicious of the way the emails are sent and confirmation page is loaded as they are both done via an Include. I'm not sure why they weren't just turned into functions and called but this is how it is. Could the included scripts be passing the execution time and not be passing the Timeout error back to the main script?

Please let me know your thoughts on this, I'm stumped



Travis Hawkins
jobs.bestcodingpractices.com
 
i suggest that you footprint the code with writes to the filesystem so you can debug later.
e.g.

Code:
function debuglog($script, $line, $message){
  $fh = fopen('myDebugFile.txt', 'a');
  fputcsv($fh, array(time(), $script, $line, $message));
  fclose ($fh);
}


debuglog(__FILE__, __LINE__, 'sending first email');

you can use this to log variable values too, of course.
 
Thanks for the suggestion, I've actually done this with a DB log. What I've found is it either gets there with everything in tact, all variables as they should be, or it doesn't get there at all. This is oversimplified but let me show you how odd it is:

breaking into the process toward the end where the problem is:
Code:
if ($success) {
  include('confirmationpage.php');
  logdb('hit conf', print_r($data,true));
  include('sendconfemail.php');
  logdb('sent conf', print_r($data,true));
}

now, inside sendconfemail.php I have a try/catch that will send me an email if there is any error and I have never received an error from that. Usually both 'hit conf' and 'sent conf' are logged in the DB. However, sometimes 'hit conf' is logged but not 'sent conf'. This would tell me there is an error in sendconfemail.php but no matter how I wrap the try/catch I can't CATCH the error. It seems like PHP just STOPS processing the page. I've traced all code paths and there are no "Exit" functions. The timeout is actually set really high as the previous programmer felt that would fix anything, it's around 10 minutes on that page and the DB logging shows it usually takes about 1-3 minutes to finish the page.

Please let me know if you have any other ideas.




Travis Hawkins
jobs.bestcodingpractices.com
 
two other ideas.

1. let us see sendconfemail.php
2. use phpmailer

 
also please let us know what platform and php version you are using
 
the sendconfemail.php script is too long to post. All it really does is pulls the purchase data back up from the DB and create an email from a template in the db.

... the other suggestion though, I think you might be on to something. the mailer is a home grown class that has some funny error handling. It's possible it's just hiding the error someplace, that's what I'm looking for today.

This is a WIMP setup. Win2k, php5.2, MySQL 5.1

This is the other area I'm a little suspicious of and hoping maybe someone had some experience with. I was wondering if maybe IIS has it's own timeout that is dropping the process even if it's not done in PHP.


Travis Hawkins
jobs.bestcodingpractices.com
 
IIS does indeed have its own timeout. but one would think this kind of script is being called via a cron job or directly via the command line?

have a look for CGI script timeout in the properties dialog (IIS Properties -> Master Properties = -> Edit -> HomeDirectory->Configuration->Process Options)
 
unfortunately this is just a standard airline ticket booking/purchase process. It's complex, it takes some time, and the user needs to be shown a confirmation page when it's done. Thanks for the directions on the CGI script timeout, I'm going to play with that value and see if I can get this problem cleared up.

Travis Hawkins
jobs.bestcodingpractices.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top