From c2eb55c8dc14bd2b440799f8ed4eabbc5275ab30 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 16 Nov 2026 18:48:57 -0500 Subject: [PATCH] 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 --- CHANGELOG.md | 4 +- admin/database_updates/3.7.1.php | 23 ++++++++ admin/mail_queue.php | 2 +- .../mail_queue/mail_queue_message_view.php | 9 ++-- admin/post/mail_queue.php | 6 +-- cron/mail_queue.php | 8 +-- cron/nightly_tasks.php | 3 +- db.sql | 1 + functions/app.php | 4 +- functions/contract_signature.php | 2 +- functions/email.php | 6 ++- functions/mail_queue.php | 53 +++++++++++++++++-- functions/portal.php | 4 +- functions/portal_invite.php | 4 +- functions/share.php | 4 +- functions/ticket.php | 2 +- functions/user_invite.php | 2 +- 17 files changed, 107 insertions(+), 30 deletions(-) create mode 100644 admin/database_updates/3.7.1.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e5b5b51d..f54c3f0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow. ### Upgrading -Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's four database changes (3.6.6 to 3.7.0) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, and change nothing that is there. Nothing else is required. This release has four security fixes - see Security. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's five database changes (3.6.6 to 3.7.1) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, and a column marking the emails the mail queue clears once sent, and change nothing that is there. Nothing else is required. This release has four security fixes - see Security. ### Security @@ -62,6 +62,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Imports: vendors, domains, certificates, licenses and services import too, from Import under the arrow beside each list's New button. Vendors go to the client whose vendors it's opened from, or are your own when it's opened from your vendors. A new domain is looked up, and a certificate with a host is checked, on its refresher's next run. A license's Assets and Contacts give it seats, and a service's Runs On, Vendors, People and Domains link it to them - by name, added to what it has. A license Type that isn't a software type yet is added. - Pictures: your picture, a user's and a contact's, and the photos of assets, locations and racks, show on their form as the picture itself with a camera on it - the person's initials, or a camera, when there isn't one. Click it to open the Picture window: drop, paste or choose a picture, crop it to fit the shape it's shown in - a circle for a person - by dragging and zooming, turn it a quarter at a time, and Use this picture, or Remove the one there is. Photos of assets, locations and racks can also be square, 4:3, 3:4 or the whole photo. What's kept is what's in the frame, at up to 512 pixels across for a person and 2048 for a photo, so a big phone photo goes in at a sensible size, the right way up, without its location or camera details. A person's initials follow their name as it's typed. - Receipts and logos open in the Picture window too: an expense's receipt (on its form, and on its quick look, where it's saved as soon as it's used) and your company's logo (Admin > Settings > Company details, and the setup wizard, where your own picture works the same way). They have no set shape - drag the frame's corners and edges in to just the receipt or logo. Trim the edges cuts the empty or plain-coloured space round a logo, and a PNG logo keeps its see-through background. A receipt can still be a PDF, which goes in as it is. A receipt is kept at up to 2400 pixels, so it stays readable, and a logo at up to 1200. +- Mail queue: a sent email keeps what it said, its attachments and its calendar file, so you can open it in Admin > Mail Queue and see exactly what went - until it's deleted after 90 days, as before. Until now every email was cleared as it was sent. An email with a link or code that opens something - a shared login and its code, a client portal or agent invite, a password link, a contract to sign or a task to approve - is still cleared once it's sent, and a day after it was queued if it failed or was cancelled. One cleared like that can't be retried: send a new one from where it came from. Emails sent before this update stay cleared. ### Bug Fixes @@ -111,6 +112,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - `cron/ticket_email_parser.php` no longer writes its run summary to App Logs - it echoes the counts and the time for a run from the command line - and ends with `cronJobStop("No mailbox is set up to read - see Admin > Settings > Mail")` when `config_imap_provider` is empty instead of logging. `cron/mail_queue.php` does the same with no `config_smtp_provider`. `cron/mail_queue.php`, `ticket_sla.php`, `domain_refresher.php` and `certificate_refresher.php` stop with `config_enable_cron` off without a `logApp()` error, as the parser has since 26.11.4. - `apiKeyFromRequest()` (`functions/api_keys.php`) reads the key an API call came with for `api/v1/validate_api_key.php` - the `X-API-Key` header (`HTTP_X_API_KEY`), else the JSON body's `api_key`, else the query string's; one that's empty or not a string counts as none, a 401 with an empty body. The key was also escaped twice on its way in; it's escaped once now. - Database 3.7.0: `api_keys.api_key_address_at`, when a key last came in a call's address (`apiKeyNoteAddress()`, at most once a minute), and `settings.config_api_key_in_address` - on where a key that hadn't expired was there at the update, off otherwise and in `db.sql`. `apiKeyInAddress()` says whether a call's query string has an `api_key`. With `apiKeyInAddressAccepted()` false (read guarded, so true before the update), `api/v1/validate_api_key.php` answers a working key in the address with a 401 and a message, and logs it as an `API` `Failed` against the key without counting it toward `apiKeyWatch()` - even when a header sends the key too, as the address is logged all the same. Admin > API Keys reads `api_key_address_at` for its flag and note, and Admin > Settings > Security saves the switch. +- Database 3.7.1: `email_queue.email_sensitive`, set by `emailQueue()`'s new `sensitive` option (`addToMailQueue()` writes it once the column is there, `mailQueueHasSensitive()`). It is passed by `shareEmailLink()`, `shareEmailCode()`, `portalInviteMail()`, `portalMailInvite()` and `portalMailSignupExists()` when the account is local, `portalMailPasswordReset()`, `userInviteMail()`, `contractSignatureRequestEmail()` and `ticketMailTaskApproval()`. `cron/mail_queue.php` marks an email sent with `mailQueueSentSql()`, which clears `email_content`, `email_cal_str` and `email_attachments` only where `email_sensitive` is 1 - every email before the update, as before. `mailQueueClearSensitive()` (nightly) clears a failed or cancelled one a day after it was queued. Retry (`mailQueueCan()`, `mailQueueAct()`) needs `email_content`, and Admin > Mail Queue reads `email_content = '' AS email_cleared` for it. The update marks the emails waiting or being sent as sensitive, as they would have been cleared. ## [26.11.8] diff --git a/admin/database_updates/3.7.1.php b/admin/database_updates/3.7.1.php new file mode 100644 index 000000000..98687aeb9 --- /dev/null +++ b/admin/database_updates/3.7.1.php @@ -0,0 +1,23 @@ + '' 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 diff --git a/admin/modals/mail_queue/mail_queue_message_view.php b/admin/modals/mail_queue/mail_queue_message_view.php index ffb2466f6..b70a2a810 100644 --- a/admin/modals/mail_queue/mail_queue_message_view.php +++ b/admin/modals/mail_queue/mail_queue_message_view.php @@ -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) { ?>
+ ? '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.') ?>
diff --git a/admin/post/mail_queue.php b/admin/post/mail_queue.php index 315eacc63..a31a35f63 100644 --- a/admin/post/mail_queue.php +++ b/admin/post/mail_queue.php @@ -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.'], ]; diff --git a/cron/mail_queue.php b/cron/mail_queue.php index efe68c6ff..d30356231 100644 --- a/cron/mail_queue.php +++ b/cron/mail_queue.php @@ -429,8 +429,8 @@ if (mysqli_num_rows($sql_queue) > 0) { (string)$config_mail_oauth_access_token_expires_at ); - // 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 = '', email_attachments = ''" . mailQueueErrorSql(null) . " WHERE email_id = $email_id"); + // Sent - one with a link or code that opens something is cleared now (mailQueueSentSql()) + mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = 1" . mailQueueSentSql() . mailQueueErrorSql(null) . " WHERE email_id = $email_id"); } catch (\Throwable $e) { // Anything that stops this one email - not only PHPMailer's own Exception, which is what Exception names @@ -511,8 +511,8 @@ if (mysqli_num_rows($sql_failed_queue) > 0) { (string)$config_mail_oauth_access_token_expires_at ); - // 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 = '', email_attachments = ''" . mailQueueErrorSql(null) . " WHERE email_id = $email_id"); + // Sent - one with a link or code that opens something is cleared now (mailQueueSentSql()) + mysqli_query($mysqli, "UPDATE email_queue SET email_status = 3, email_sent_at = NOW(), email_attempts = $email_attempts" . mailQueueSentSql() . mailQueueErrorSql(null) . " WHERE email_id = $email_id"); } catch (\Throwable $e) { mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = $email_attempts" . mailQueueErrorSql($e->getMessage()) . " WHERE email_id = $email_id"); diff --git a/cron/nightly_tasks.php b/cron/nightly_tasks.php index 0108d45ad..c09ef181f 100644 --- a/cron/nightly_tasks.php +++ b/cron/nightly_tasks.php @@ -162,7 +162,8 @@ mysqli_query($mysqli, "UPDATE users SET user_password_reset_token = NULL, user_p // Clean-up old dismissed notifications mysqli_query($mysqli, "DELETE FROM notifications WHERE notification_dismissed_at < CURDATE() - INTERVAL 90 DAY"); -// Clean-up mail queue +// Clean-up mail queue - a failed or cancelled email with a link or code that opens something is cleared after a day, everything is deleted after 90 +mailQueueClearSensitive(); mysqli_query($mysqli, "DELETE FROM email_queue WHERE email_queued_at < CURDATE() - INTERVAL " . MAIL_QUEUE_KEEP_DAYS . " DAY"); // Clean-up the PDFs made to go with billing emails - sent or given up on by now diff --git a/db.sql b/db.sql index de2aaa938..02210c57d 100644 --- a/db.sql +++ b/db.sql @@ -1683,6 +1683,7 @@ CREATE TABLE `email_queue` ( `email_attempts` tinyint(1) NOT NULL DEFAULT 0, `email_sent_at` datetime DEFAULT NULL, `email_ticket_reply_id` int(11) DEFAULT NULL, + `email_sensitive` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`email_id`), KEY `email_status` (`email_status`,`email_queued_at`), KEY `email_ticket_reply_id` (`email_ticket_reply_id`) diff --git a/functions/app.php b/functions/app.php index 6ad0313a5..b3443ac42 100644 --- a/functions/app.php +++ b/functions/app.php @@ -849,8 +849,10 @@ function addToMailQueue($data) { // The ticket reply it carries (emailQueue()'s ticket_reply_id), once the 3.4.8 update has made the column $ticket_reply_sql = !empty($email['ticket_reply_id']) ? ', email_ticket_reply_id = ' . intval($email['ticket_reply_id']) : ''; + // One with a link or code that opens something, cleared once it has gone (emailQueue()'s sensitive) - once the 3.7.1 update has made the column + $sensitive_sql = !empty($email['sensitive']) && mailQueueHasSensitive() ? ', email_sensitive = 1' : ''; - mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$recipient', email_recipient_name = '$recipient_name', email_from = '$from', email_from_name = '$from_name', email_subject = '$subject', email_content = '$body', email_queued_at = $queued_at, email_cal_str = '$cal_str', email_attachments = '$attachments'$ticket_reply_sql"); + mysqli_query($mysqli, "INSERT INTO email_queue SET email_recipient = '$recipient', email_recipient_name = '$recipient_name', email_from = '$from', email_from_name = '$from_name', email_subject = '$subject', email_content = '$body', email_queued_at = $queued_at, email_cal_str = '$cal_str', email_attachments = '$attachments'$ticket_reply_sql$sensitive_sql"); } return true; diff --git a/functions/contract_signature.php b/functions/contract_signature.php index 7fe4b2e65..704db166b 100644 --- a/functions/contract_signature.php +++ b/functions/contract_signature.php @@ -564,7 +564,7 @@ function contractSignatureRequestEmail(array $round, $note = '') { 'note' => trim((string) $note), 'summary' => array_filter(['Contract' => (string) $round['contract_name'], 'For' => (string) $round['client_name'], 'Term' => $term, 'Sent by' => (string) $by]), 'button' => ['label' => 'Review and sign', 'url' => contractSignatureUrl($round)], - ], ['from' => contractEmailFrom()]); + ], ['from' => contractEmailFrom(), 'sensitive' => true]); return (bool) $sent; } diff --git a/functions/email.php b/functions/email.php index 1a2a0b22e..61b9dc757 100644 --- a/functions/email.php +++ b/functions/email.php @@ -343,6 +343,9 @@ function emailPlainText($html, $limit = 0) { * ticket_reply_id the agent's ticket reply it carries - kept with each email * (email_queue.email_ticket_reply_id), so the conversation says who * it went to and whether it went (ticketReplyEmailed()) + * sensitive it carries a link or code that opens something - a shared login, an + * invite, a password link, a signing or approval link - so the mail queue + * clears what it said once it has gone (email_queue.email_sensitive) * Who it was queued to, "Name (email)". Nothing is queued without mail set up. */ function emailQueue(array $recipients, $subject, array $email, array $opts = []) { @@ -380,7 +383,8 @@ function emailQueue(array $recipients, $subject, array $email, array $opts = []) 'attachments' => $attachments, ] + (!empty($opts['cal_str']) ? ['cal_str' => (string) $opts['cal_str']] : []) + ($queued_at !== '' ? ['queued_at' => $queued_at] : []) - + (intval($opts['ticket_reply_id'] ?? 0) > 0 && ticketReplyEmailReady() ? ['ticket_reply_id' => intval($opts['ticket_reply_id'])] : []); + + (intval($opts['ticket_reply_id'] ?? 0) > 0 && ticketReplyEmailReady() ? ['ticket_reply_id' => intval($opts['ticket_reply_id'])] : []) + + (!empty($opts['sensitive']) ? ['sensitive' => 1] : []); } if ($data) { addToMailQueue($data); diff --git a/functions/mail_queue.php b/functions/mail_queue.php index 9fb706d3f..ead12d764 100644 --- a/functions/mail_queue.php +++ b/functions/mail_queue.php @@ -10,8 +10,11 @@ * 1 being sent this minute * 2 failed - tried again every MAIL_QUEUE_RETRY_MINUTES until it has had * MAIL_QUEUE_TRIES; 99 tries means it isn't tried again (a bad address) - * 3 sent - its body, calendar file and attachments are cleared then, as - * they can carry share keys and temporary passwords + * 3 sent - it keeps what it said, its calendar file and attachments, except + * one that carried a link or code that opens something (email_sensitive: + * a shared login, an invite, a password link, a signing or approval link), + * cleared as it goes - and a failed or cancelled one like it a day after + * it was queued (nightly, mailQueueClearSensitive()) * 4 cancelled by an admin - never picked up again * email_error says why it last failed, or who cancelled it - cleared when it * is sent or retried. Sent, failed and cancelled email is deleted after 90 @@ -101,7 +104,8 @@ function mailQueueCan(array $row, $action) { $tries = intval($row['email_attempts']); switch ($action) { case 'retry': - return $status === 2 || $status === MAIL_QUEUE_CANCELLED; + // Not one whose link was cleared - there is nothing left to send + return ($status === 2 || $status === MAIL_QUEUE_CANCELLED) && empty($row['email_cleared']); case 'cancel': return $status === 0 || ($status === 2 && $tries < MAIL_QUEUE_TRIES); case 'delete': @@ -125,7 +129,7 @@ function mailQueueAct($action, array $email_ids) { $tries = MAIL_QUEUE_TRIES; $cancelled = MAIL_QUEUE_CANCELLED; $where = [ - 'retry' => "email_status IN (2, $cancelled)", + 'retry' => "email_status IN (2, $cancelled) AND email_content <> ''", 'cancel' => "(email_status = 0 OR (email_status = 2 AND email_attempts < $tries))", 'delete' => 'email_status <> 1', ][$action] ?? null; @@ -201,7 +205,7 @@ function mailQueueHealth() { 'url' => 'cron.php', 'action' => 'Maintenance > Cron', 'waiting' => $waiting]; } return ['level' => '', 'key' => 'ok', 'title' => '', 'text' => 'Sent by the Mail Queue job each minute - it last ran ' . $ago($job['cron_job_last_run_at'] ?? null) . '. A failed email is tried ' - . (MAIL_QUEUE_TRIES - 1) . ' more times, ' . MAIL_QUEUE_RETRY_MINUTES . ' minutes apart. Email is kept ' . MAIL_QUEUE_KEEP_DAYS . ' days; a sent one without what it said.', 'url' => '', 'action' => '', 'waiting' => 0]; + . (MAIL_QUEUE_TRIES - 1) . ' more times, ' . MAIL_QUEUE_RETRY_MINUTES . ' minutes apart. Email is kept ' . MAIL_QUEUE_KEEP_DAYS . ' days - with what it said, apart from one with a link or code that opens something, cleared once it has gone.', 'url' => '', 'action' => '', 'waiting' => 0]; } /* Whether email_queue has email_error yet - not until the 3.3.7 update has run. */ @@ -242,6 +246,45 @@ function mailQueueErrorColumn() { return mailQueueHasError() ? 'email_error' : 'NULL AS email_error'; } +/* Is there an email_sensitive column yet? Database 3.7.1 adds it. */ +function mailQueueHasSensitive() { + global $mysqli; + static $has = null; + if ($has === null) { + $result = mysqli_query($mysqli, "SHOW COLUMNS FROM email_queue LIKE 'email_sensitive'"); + $has = $result && mysqli_num_rows($result) > 0; + } + return $has; +} + +/* + * What an email that has gone keeps, for the UPDATE that marks it sent (cron/mail_queue.php): + * everything, unless it carried a link or code that opens something - then what it said, its + * calendar file and attachments are cleared. Before the update that says which those are, + * every one is cleared, as all were. + */ +function mailQueueSentSql() { + if (!mailQueueHasSensitive()) { + return ", email_content = '', email_cal_str = '', email_attachments = ''"; + } + return ", email_content = IF(email_sensitive = 1, '', email_content), email_cal_str = IF(email_sensitive = 1, '', email_cal_str)," + . " email_attachments = IF(email_sensitive = 1, '', email_attachments)"; +} + +/* + * Clear what a failed or cancelled email with a link or code said, a day after it was queued + * - its tries are long over, and a new one is a new link anyway (nightly). How many. + */ +function mailQueueClearSensitive() { + global $mysqli; + if (!mailQueueHasSensitive()) { + return 0; + } + mysqli_query($mysqli, "UPDATE email_queue SET email_content = '', email_cal_str = '', email_attachments = '' + WHERE email_sensitive = 1 AND email_status IN (2, " . MAIL_QUEUE_CANCELLED . ") AND email_content <> '' AND email_queued_at < NOW() - INTERVAL 1 DAY"); + return mysqli_affected_rows($mysqli); +} + /* * The mail queue at a glance, for the pages that point to it - how many are * waiting (due now), retrying, and given up on in the last day and the last diff --git a/functions/portal.php b/functions/portal.php index 34f140538..ff7baaa22 100644 --- a/functions/portal.php +++ b/functions/portal.php @@ -345,7 +345,7 @@ function portalMailInvite($user_id, $by = '') { 'summary' => ['Sign in as' => (string) $row['user_email']], 'button' => $button, 'after' => [$after], - ]); + ], ['sensitive' => $row['user_auth_method'] === 'local']); } /** A Forgot password link for a portal user, good for PORTAL_RESET_LINK_MINUTES. False when it can't go. */ @@ -366,7 +366,7 @@ function portalMailPasswordReset($user_id) { 'summary' => ['Account' => (string) $row['user_email']], 'button' => ['label' => 'Set a new password', 'url' => portalPasswordLink($user_id, PORTAL_RESET_LINK_MINUTES)], 'after' => ['The link works once, for the next ' . PORTAL_RESET_LINK_MINUTES . ' minutes. If you did not ask for it, ignore this email - your password stays as it is.'], - ]); + ], ['sensitive' => true]); } /* diff --git a/functions/portal_invite.php b/functions/portal_invite.php index 0c975968f..bc79cdc15 100644 --- a/functions/portal_invite.php +++ b/functions/portal_invite.php @@ -272,7 +272,7 @@ function portalInviteMail($invite_id, $token) { ]; $footnote = "You received this because $who invited this address to the $company_name client portal."; } - $sent = (bool) emailQueue([['email' => (string) $row['invite_email'], 'name' => $greet, 'greet' => $greet !== '' ? $greet : null, 'footnote' => $footnote]], $subject, $email); + $sent = (bool) emailQueue([['email' => (string) $row['invite_email'], 'name' => $greet, 'greet' => $greet !== '' ? $greet : null, 'footnote' => $footnote]], $subject, $email, ['sensitive' => true]); if ($sent && !emailCapturing()) { mysqli_query($mysqli, "UPDATE portal_invites SET invite_sent_at = NOW(), invite_sent_count = invite_sent_count + 1 WHERE invite_id = " . intval($row['invite_id'])); } @@ -808,7 +808,7 @@ function portalMailSignupExists($user_id) { 'summary' => ['Account' => (string) $row['user_email']], 'button' => $local ? ['label' => 'Set a new password', 'url' => portalPasswordLink($user_id, PORTAL_RESET_LINK_MINUTES)] : ['label' => 'Sign in', 'url' => "https://$config_base_url/login.php"], 'after' => [$local ? 'The link works once, for the next ' . PORTAL_RESET_LINK_MINUTES . ' minutes. If you did not ask, ignore this email - your account stays as it is.' : 'If you did not ask, ignore this email - your account stays as it is.'], - ]); + ], ['sensitive' => $local]); } /** Set whether people at a client can sign up. True when it changed. */ diff --git a/functions/share.php b/functions/share.php index 3477ae0cd..27934e3ec 100644 --- a/functions/share.php +++ b/functions/share.php @@ -665,7 +665,7 @@ function shareEmailLink($row, $url, $protect) { 'summary' => $summary, 'callout' => $callout, 'button' => ['label' => $button, 'url' => (string) $url, 'show_url' => true], - ], ['from' => shareMailFrom()]); + ], ['from' => shareMailFrom(), 'sensitive' => true]); } /** The code that opens a link protected by one, to its recipient. True when it was queued. */ @@ -677,7 +677,7 @@ function shareEmailCode($row, $code) { 'title' => "Your code is $code", 'intro' => ['Enter it on the page that asked for it, to open the secure link ' . $company['name'] . ' sent you. It works for ' . SHARE_CODE_MINUTES . ' minutes.'], 'callout' => 'If you did not ask for it, someone else has the link - ignore this email and let us know.', - ], ['from' => shareMailFrom()]); + ], ['from' => shareMailFrom(), 'sensitive' => true]); } /** diff --git a/functions/ticket.php b/functions/ticket.php index 8760af36f..abcc1a052 100644 --- a/functions/ticket.php +++ b/functions/ticket.php @@ -1049,7 +1049,7 @@ function ticketMailTaskApproval($approval_id, $by) { 'button' => ['label' => 'Review and approve', 'url' => "https://$config_base_url/guest/guest_approve_ticket_task.php?task_approval_id=" . intval($approval['approval_id']) . '&url_key=' . rawurlencode((string) $approval['approval_url_key'])], 'after' => ['Want to know more first? Just reply to this email.'], 'contact' => ticketEmailContactLine(), - ], ['from' => ticketEmailFrom()])); + ], ['from' => ticketEmailFrom(), 'sensitive' => true])); } /* diff --git a/functions/user_invite.php b/functions/user_invite.php index 6c0ba3cdb..d587fa893 100644 --- a/functions/user_invite.php +++ b/functions/user_invite.php @@ -398,7 +398,7 @@ function userInviteMail($invite_id, $token) { 'summary' => $summary, 'button' => ['label' => 'Accept the invite', 'url' => userInviteUrl($row['invite_id'], $token)], 'after' => ['The invite works for ' . USER_INVITE_LINK_DAYS . ' days. If you were not expecting it, you can ignore this email - nothing is set up unless the link is used.'], - ]); + ], ['sensitive' => true]); if ($sent && !emailCapturing()) { mysqli_query($mysqli, "UPDATE user_invites SET invite_sent_at = NOW(), invite_sent_count = invite_sent_count + 1 WHERE invite_id = " . intval($row['invite_id'])); }