Mail queue keeps what a sent email said: only an email with a link or code that opens something - a shared login and its code, a portal or agent invite, a password link, a contract to sign or a task to approve - is cleared once sent, and a day after it was queued if it failed or was cancelled; emailQueue gains a sensitive option set by those senders, cron marks sent email with mailQueueSentSql, nightly runs mailQueueClearSensitive, and a cleared email can't be retried; database 3.7.1 adds email_queue.email_sensitive and marks email waiting at the update; 26.11.9 changelog entries

This commit is contained in:
johnnyq
2026-11-16 18:48:57 -05:00
parent 8784c50abe
commit c2eb55c8dc
17 changed files with 107 additions and 30 deletions

View File

@@ -0,0 +1,23 @@
<?php
/*
* ITFlow - Database update to version 3.7.1 (from 3.7.0)
* Included by admin/database_updates.php - do not access directly
*
* The mail queue keeps what a sent email said (functions/mail_queue.php):
* email_queue.email_sensitive - an email with a link or code that opens something (a shared
* login, an invite, a password link, a signing or approval link), cleared once it has gone.
* Every other email keeps what it said until it is deleted after 90 days. Each one waiting
* or going now is marked, as it would have been cleared once sent before this update.
*
* Re-runnable: the column is made, and those marked, only where it isn't there yet.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
$itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'email_queue' AND COLUMN_NAME = 'email_sensitive' LIMIT 1");
if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) {
mysqli_query($mysqli, "ALTER TABLE `email_queue` ADD `email_sensitive` tinyint(1) NOT NULL DEFAULT 0 AFTER `email_ticket_reply_id`");
mysqli_query($mysqli, "UPDATE `email_queue` SET `email_sensitive` = 1 WHERE `email_status` IN (0, 1)");
}

View File

@@ -39,7 +39,7 @@ $search = "(email_id LIKE '%$q%' OR email_from LIKE '%$q%' OR email_from_name LI
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
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, email_content = '' AS email_cleared
FROM email_queue
WHERE $search AND {$tabs[$show][2]}
ORDER BY {$sortable_columns[$sort]}, email_id DESC

View File

@@ -4,7 +4,8 @@
* Maintenance > Mail Queue - one email: where it stands, and why it last
* failed or who cancelled it; who it is to and from; when it was queued,
* tried, sent or given up on; its attachments and calendar file; and what it
* says, until it is sent - that is cleared then (cron/mail_queue.php). The
* says - unless it carried a link or code that opens something, cleared once it
* has gone (functions/mail_queue.php). The
* email is shown as it will arrive, in a sandboxed frame that runs nothing
* and can't reach this page. Retry now, Cancel and Delete as on its row
* (admin/post/mail_queue.php).
@@ -14,7 +15,7 @@ require_once '../../includes/modal_header.php';
$email_id = intval($_GET['id'] ?? 0);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT email_id, email_status, email_attempts, email_from, email_from_name, email_recipient, email_recipient_name,
email_subject, email_content, email_cal_str, email_attachments, email_queued_at, email_failed_at, email_sent_at, " . mailQueueErrorColumn() . "
email_subject, email_content, email_content = '' AS email_cleared, email_cal_str, email_attachments, email_queued_at, email_failed_at, email_sent_at, " . mailQueueErrorColumn() . "
FROM email_queue WHERE email_id = $email_id LIMIT 1"));
ob_start();
@@ -122,8 +123,8 @@ if (!$row) { ?>
<div class="text-center text-body-secondary border rounded py-4 px-3" data-email-cleared>
<i class="fas fa-fw fa-eraser fa-lg mb-2 d-block"></i>
<?= $status === 3
? 'What it said was cleared when it was sent - an email can carry share links and temporary passwords, so it isn\'t kept.'
: 'There is nothing in it.' ?>
? 'What it said was cleared when it was sent - it carried a link or code that opens something, such as a shared login, an invite or a password link, so it isn\'t kept.'
: (in_array($status, [2, MAIL_QUEUE_CANCELLED], true) ? 'What it said was cleared a day after it was queued - it carried a link or code that opens something, so it isn\'t kept. Send a new one from where it came from.' : 'There is nothing in it.') ?>
</div>
<?php } else { ?>
<!-- As it will arrive - sandboxed: nothing in it runs, and it can't reach this page; its links open on their own -->

View File

@@ -5,15 +5,15 @@
* start, cancel it or delete it - one (retry_mail, cancel_mail, delete_mail)
* or the ones ticked (bulk_retry_emails, bulk_cancel_emails,
* bulk_delete_emails). Each is only done where it can be (mailQueueAct(),
* functions/mail_queue.php) - a sent email can't be retried, as what it said
* was cleared on sending, and one going this minute is left alone - and the
* functions/mail_queue.php) - a sent email can't be retried, nor one whose
* link was cleared, and one going this minute is left alone - and the
* message says how many it was done to, and why any weren't.
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
$mail_queue_actions = [
'retry' => ['retry_mail', 'bulk_retry_emails', 'retried', 'Retry', ['it goes at the next run', 'they go at the next run'], 'A sent one can\'t be - what it said was cleared on sending - nor one waiting or going now.'],
'retry' => ['retry_mail', 'bulk_retry_emails', 'retried', 'Retry', ['it goes at the next run', 'they go at the next run'], 'A sent one can\'t be, nor one waiting or going now, nor one whose link was cleared.'],
'cancel' => ['cancel_mail', 'bulk_cancel_emails', 'cancelled', 'Cancel', ['it won\'t be sent', 'they won\'t be sent'], 'Only one still to be sent or tried again can be.'],
'delete' => ['delete_mail', 'bulk_delete_emails', 'deleted', 'Delete', ['', ''], 'One going this minute can\'t be.'],
];