summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-05-29 23:52:11 -0700
committerPatrick Davison <snapwilliam@gmail.com>2013-05-29 23:52:11 -0700
commite58a3b8b3702b22c903b02a9b4fa1020d6797459 (patch)
tree8af52b654ce5f726ab7d53a35e13d841716ad0f1
parent0de677ff1e4506b098738aa1b8729f908fcd718e (diff)
downloadpathery-e58a3b8b3702b22c903b02a9b4fa1020d6797459.tar.xz
Fixed crazy email bug.
-rw-r--r--includes/emails.php22
1 files 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 "<br> 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 "<br> Deletes Complete";
} catch (Exception $exc) { /* Ignore... :| */ }
//Release Lock
releaseEmailLock($lock);
- //TODO !!
- //echo "<br>I DIDN'T SEND THIS: ($body, $subject, $to)<br>";
- //SendEmail($body, $subject, "snapwilliam@gmail.com");
- //SendEmail($body, $subject, $to);
-
return true;
}