Mail Queue - every email ITFlow sends, from being queued to * sent, and what came of it (functions/mail_queue.php says what each status * is). The tabs pick Waiting, Sending, Retrying, Failed, Sent or Cancelled, * each with how many; at the top, anything stopping the queue moving - * sending switched off, cron not running, the job off, or email waiting * longer than it should. An email can be retried from the start, cancelled * or deleted, one at a time or several (admin/post/mail_queue.php), and * opened to see it (modals/mail_queue/mail_queue_message_view.php). */ // Default Column Sortby Filter $sort = "email_queued_at"; $order = "DESC"; require_once "includes/inc_all_admin.php"; $page_title = 'Mail Queue'; $tabs = mailQueueTabs(); $show = (string) ($_GET['show'] ?? ''); $show = isset($tabs[$show]) ? $show : ''; // Only these sort - an unknown column would take the page down $sortable_columns = [ 'email_queued_at' => "email_queued_at $order", 'email_recipient' => "email_recipient $order, email_queued_at DESC", 'email_subject' => "email_subject $order, email_queued_at DESC", 'email_status' => "FIELD(email_status, 2, 1, 0, 4, 3) $order, email_attempts DESC, email_queued_at DESC", ]; if (!isset($sortable_columns[$sort])) { $sort = 'email_queued_at'; } $search = "(email_id LIKE '%$q%' OR email_from LIKE '%$q%' OR email_from_name LIKE '%$q%' OR email_recipient LIKE '%$q%' OR email_recipient_name LIKE '%$q%' OR email_subject LIKE '%$q%'" . (mailQueueHasError() ? " OR email_error LIKE '%$q%'" : '') . ") AND DATE(email_queued_at) BETWEEN '$dtf' AND '$dtt'"; $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS email_id, email_status, email_attempts, email_from, email_from_name, email_recipient, email_recipient_name, email_subject, email_queued_at, email_failed_at, email_sent_at, " . mailQueueErrorColumn() . ", COALESCE(email_attachments, '') <> '' AS has_attachments, COALESCE(email_cal_str, '') <> '' AS has_invite FROM email_queue WHERE $search AND {$tabs[$show][2]} ORDER BY {$sortable_columns[$sort]}, email_id DESC LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); // How many in each tab, as searched $count_sql = []; foreach ($tabs as $key => [, , $where]) { $count_sql[] = "COALESCE(SUM($where), 0)"; } $counts = array_combine(array_keys($tabs), array_map('intval', mysqli_fetch_row(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " FROM email_queue WHERE $search")))); $health = mailQueueHealth(); $sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $disp, $order_icon) { return '' . $label . ($sort === $column ? " $order_icon" : '') . ''; }; $pill_url = function ($show) { return '?' . http_build_query(array_filter(['q' => $_GET['q'] ?? '', 'show' => $show, 'canned_date' => $_GET['canned_date'] ?? '', 'dtf' => $_GET['dtf'] ?? '', 'dtt' => $_GET['dtt'] ?? ''])); }; $person = function ($name, $address) { $name = trim((string) $name); $address = (string) $address; if ($address === '') { return ($name !== '' ? '' . escapeHtml($name) . ' ' : '') . 'no address'; } if ($name === '' || strcasecmp($name, $address) === 0) { return '' . escapeHtml($address) . ''; } return '' . escapeHtml($name) . ' ' . escapeHtml($address) . ''; }; $csrf = $_SESSION['csrf_token']; $filtered_dates = isset($_GET['dtf']) && $_GET['dtf'] !== '' && $_GET['dtf'] !== '1970-01-01'; ?>

Mail Queue

-
"> (no subject)'; $view = 'data-modal-size="lg" data-modal-url="modals/mail_queue/mail_queue_message_view.php?id=' . $email_id . '"'; $from = $person($row['email_from_name'], $row['email_from']); ?>
>
From
#
'emails', 'icon' => 'fa-inbox', 'title' => $show !== '' ? 'Nothing ' . strtolower($tabs[$show][0]) : 'Nothing in the mail queue', 'text' => 'The email ITFlow sends waits here until it goes, and stays ' . MAIL_QUEUE_KEEP_DAYS . ' days after.', ]; ?>