Hello
To handle an occasionnal flaky ADSL connection, I updated the
database that handles incoming calls to have a column that is set to
NULL, and then updated to either Y or N depending on whether a PHP CLI
script was able to send a notification e-mail to support.
To send an e-mail through out ISP's SMTP server, I'm using PHPMailer
2.0.0 rc3 http://phpmailer.sourceforge.net which worked fine until we
had some connection loss. I'm at a loss as to why some (not all) new
call records are left to NULL instead of being updated to Y or N :-/
Here's the code:
=========
require("/usr/local/share/asterisk/agi-bin/php_mailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.isp.com";
$mail->From = "se****@acme.com";
$mail->FromName = "From Server";
$mail->AddAddress("su*****@acme.com");
$mail->Subject = "Dummy subject";
$body = "Dummy body";
$mail->Body = $body;
$mail->WordWrap = 50;
//Why do some records remain to NULL?
$sql = "UPDATE calls SET calls_sent='%s' WHERE calls_id=$calls_id";
if(!$mail->Send()) {
//If failed, update record with calls_sent="n"
$sql = sprintf($sql,"n");
$dbh->exec($sql);
$dbh = null;
exit("Mailer error: " . $mail->ErrorInfo . "\n");
} else {
$sql = sprintf($sql,"y");
$dbh->exec($sql);
$dbh = null;
exit(0);
}=========
Any idea why it doesn't do what it's supposed to?
Thank you.