From 4c65b8c5618fa23968655cb96867d659cc8efd5f Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 28 Jul 2026 00:18:07 -0400 Subject: [PATCH] Clear mail bodies after successful delivery --- admin/modals/mail_queue/mail_queue_message_view.php | 4 +++- admin/post/mail_queue.php | 8 ++++++++ admin/post/users.php | 8 +++++++- cron/mail_queue.php | 6 ++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/admin/modals/mail_queue/mail_queue_message_view.php b/admin/modals/mail_queue/mail_queue_message_view.php index ab89db7c..abfc7f9e 100644 --- a/admin/modals/mail_queue/mail_queue_message_view.php +++ b/admin/modals/mail_queue/mail_queue_message_view.php @@ -65,7 +65,9 @@ ob_start();
- + + Message content was cleared on delivery. +
diff --git a/admin/post/mail_queue.php b/admin/post/mail_queue.php index d9e88534..bb601de0 100644 --- a/admin/post/mail_queue.php +++ b/admin/post/mail_queue.php @@ -8,6 +8,14 @@ if (isset($_GET['send_failed_mail'])) { $email_id = intval($_GET['send_failed_mail']); + // Delivered mail has had its body cleared on send, so resending would deliver an empty message + $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT email_status FROM email_queue WHERE email_id = $email_id LIMIT 1")); + + if (!$row || intval($row['email_status']) === 3) { + flashAlert("That email has already been delivered and cannot be resent.", 'error'); + redirect(); + } + mysqli_query($mysqli,"UPDATE email_queue SET email_status = 0, email_attempts = 3 WHERE email_id = $email_id"); logAudit("Email", "Send", "$session_name attempted to force send email id: $email_id in the mail queue", 0, $email_id); diff --git a/admin/post/users.php b/admin/post/users.php index 8e23f137..3bfa7028 100644 --- a/admin/post/users.php +++ b/admin/post/users.php @@ -70,8 +70,14 @@ if (isset($_POST['add_user'])) { $password = mysqli_real_escape_string($mysqli, $_POST['password']); + // Only hand out the login key when the gate is actually enabled - same test as post/logout.php + $login_url = "https://$config_base_url/login.php"; + if ($config_login_key_required == 1) { + $login_url .= "?key=$config_login_key_secret"; + } + $subject = "Your new $company_name ITFlow account"; - $body = "Hello $name,

An ITFlow account has been setup for you. Please change your password upon login.

Username: $email
Password: $password
Login URL: https://$config_base_url/login.php?key=$config_login_key_secret

--
$company_name - Support
$config_ticket_from_email"; + $body = "Hello $name,

An ITFlow account has been setup for you. Please change your password upon login.

Username: $email
Password: $password
Login URL: $login_url

--
$company_name - Support
$config_ticket_from_email"; $data = [ [ diff --git a/cron/mail_queue.php b/cron/mail_queue.php index a3e443d5..cab72968 100644 --- a/cron/mail_queue.php +++ b/cron/mail_queue.php @@ -385,7 +385,8 @@ if (mysqli_num_rows($sql_queue) > 0) { (string)$config_mail_oauth_access_token_expires_at ); - mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = 1 WHERE email_id = $email_id"); + // Scrub the body on delivery - it can carry share decryption keys and temporary passwords + mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = 1, email_content = '', email_cal_str = '' WHERE email_id = $email_id"); } catch (Exception $e) { mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = 1 WHERE email_id = $email_id"); @@ -459,7 +460,8 @@ if (mysqli_num_rows($sql_failed_queue) > 0) { (string)$config_mail_oauth_access_token_expires_at ); - mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = $email_attempts WHERE email_id = $email_id"); + // Scrub the body on delivery - it can carry share decryption keys and temporary passwords + mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = $email_attempts, email_content = '', email_cal_str = '' WHERE email_id = $email_id"); } catch (Exception $e) { mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = $email_attempts WHERE email_id = $email_id");