-
Notifications
You must be signed in to change notification settings - Fork 0
/
SendPendingEmails.php
45 lines (37 loc) · 1.15 KB
/
SendPendingEmails.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
//ini_set('include_path', '../');
//echo ini_get('include_path');
require_once('Controller/BaseController.php');
require_once('Model/BaseModel.php');
$BaseModel = new BaseModel();
$pending_emails = $BaseModel->executeQuery("
SELECT *
FROM pending_email
WHERE status = 'pending'
");
if(!is_array($pending_emails)){
exit;
}
foreach($pending_emails AS $email_information){
$id = $email_information['id'];
$to = $email_information['to'];
//$from = $email_information['from'];
$subject = $email_information['subject'];
$body = $email_information['body'];
$success = BaseController::sendEmail($to, $subject, $body, 0);
if($success){
$BaseModel->executeUpdateQuery("
UPDATE pending_email
SET status = 'sent'
WHERE id = {$id}
");
}else{
$BaseModel->executeUpdateQuery("
UPDATE pending_email
SET status = 'failed'
WHERE id = {$id}
");
BaseController::sendEmail('[email protected]', 'Failed to send email '.$to, "<b style='font-color:red'>Failed to send email</b><br/>{$body}", 0);
}
}
?>