From e58a3b8b3702b22c903b02a9b4fa1020d6797459 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 29 May 2013 23:52:11 -0700 Subject: Fixed crazy email bug. --- includes/emails.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/includes/emails.php b/includes/emails.php index 7a54a89..9b5d124 100644 --- a/includes/emails.php +++ b/includes/emails.php @@ -25,7 +25,6 @@ function SendQueuedEmail() { return false; } - //echo "
Checking Queue"; //Check the Queue $res = $mysqli->query("SELECT `emailID` FROM `emailQueue` @@ -57,27 +56,24 @@ function SendQueuedEmail() { $body = $response['body']; $success = SendEmail($body, $subject, $to); + + //Success or fail, we still want this deleted. + $mysqli->query("DELETE FROM `emailQueue` WHERE `emailID` = $emailID"); + + //TODO: Handle failed emails someplace. if (!$success) { - $res = $mysqli->query("DELETE FROM `emailQueue` WHERE `ID` = $emailID"); - $res = $mysqli->query("UPDATE `emails` SET `error` = 'Failed to send' WHERE `ID` = $emailID"); + $mysqli->query("UPDATE `emails` SET `error` = 'Failed to send' WHERE `ID` = $emailID"); return false; } - //I declare this letter sent! - $res = $mysqli->query("DELETE FROM `emailQueue` WHERE `ID` = $emailID"); - $res = $mysqli->query("UPDATE `settings` SET `value` = UNIX_TIMESTAMP(NOW()) WHERE `name` = 'Email_Last_Sent'"); - $res = $mysqli->query("UPDATE `emails` SET `dateSent` = NOW() WHERE `ID` = $emailID"); + //Success! + $mysqli->query("UPDATE `settings` SET `value` = UNIX_TIMESTAMP(NOW()) WHERE `name` = 'Email_Last_Sent'"); + $mysqli->query("UPDATE `emails` SET `dateSent` = NOW() WHERE `ID` = $emailID"); - //echo "
Deletes Complete"; } catch (Exception $exc) { /* Ignore... :| */ } //Release Lock releaseEmailLock($lock); - //TODO !! - //echo "
I DIDN'T SEND THIS: ($body, $subject, $to)
"; - //SendEmail($body, $subject, "snapwilliam@gmail.com"); - //SendEmail($body, $subject, $to); - return true; } -- cgit v1.2.3