fusionpbx/app/emails/email_cron.php

53 lines
1.4 KiB
PHP
Raw Normal View History

2016-03-11 22:03:01 +01:00
<?php
2017-01-17 02:26:23 +01:00
//restrict to command line only
if(defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
include "root.php";
require_once "resources/require.php";
require_once "resources/classes/text.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$format = 'text'; //html, text
//add multi-lingual support
$language = new text;
$text = $language->get();
}
else {
die('access denied');
}
2016-03-11 22:03:01 +01:00
2017-01-17 02:26:23 +01:00
//get the failed emails
2017-04-21 12:49:13 +02:00
$sql = "select email_uuid, email from v_emails limit 100";
2017-01-17 02:26:23 +01:00
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$emails = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//process the emails
if (is_array($emails)) {
foreach($emails as $row) {
$email_uuid = $row['email_uuid'];
$msg = $row['email'];
require_once "secure/v_mailto.php";
if ($mailer_error == '') {
//get the message
messages::add($text['message-message_resent']);
2017-01-17 02:26:23 +01:00
//delete the email
$sql = "delete from v_emails ";
$sql .= "where email_uuid = '".$email_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql, $prep_statement);
2016-03-11 22:03:01 +01:00
}
2017-01-17 02:26:23 +01:00
unset($mailer_error);
2016-03-11 22:03:01 +01:00
}
}
2017-01-17 02:26:23 +01:00
unset ($prep_statement, $sql, $emails);
2016-03-11 22:03:01 +01:00
2017-01-17 02:26:23 +01:00
?>