diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2fe226eaa..68522cb4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow.
### Upgrading to 26.12.3
-Update from Maintenance > Update as usual - this release has eleven database changes: 4.2.2 adds a table for passkeys and a setting to turn them on or off, 4.2.3 lets a document keep the Markdown it was written in, 4.2.4 lets a ticket keep its pictures as files, 4.2.5 adds identity providers, 4.2.6 keeps each ticket's email conversation together, 4.2.7 lets a reply from a CC say who sent it, 4.2.8 renames the watchers table for CCs, 4.2.9 lets the mail queue go at a pace your mail host takes, 4.3.0 lets contacts unsubscribe from bulk email, 4.3.1 encrypts the mail passwords and tokens, and 4.3.2 keeps the email the ticket mailbox couldn't take, for your team to sort. The client portal's Microsoft 365 single sign-on becomes the first identity provider, for client contacts, and keeps its redirect address, so nothing changes in Microsoft Entra. Nothing else is required: passkeys are on, and no one has one until they add it. Pictures already inside tickets move to files in the background afterwards - the new Ticket Pictures job in Maintenance > Cron does a batch a minute, so an install with years of emailed screenshots may take a while, and tickets work as usual meanwhile. A passkey is made for your ITFlow's address (the one in config.php) and only works there, over HTTPS - if you move ITFlow to a new address, everyone adds theirs again. Watchers are called CCs now. Emails about a ticket go to its contact with the CCs copied in, rather than one each - Admin > Settings > Tickets has the switch, under Emails about a ticket. On nginx, where ITFlow's .htaccess files aren't read, add `location ^~ /uploads/mail_unprocessed/ { deny all; }` beside the other private folders - it holds copies of the email kept for Unprocessed Email.
+Update from Maintenance > Update as usual - this release has twelve database changes: 4.2.2 adds a table for passkeys and a setting to turn them on or off, 4.2.3 lets a document keep the Markdown it was written in, 4.2.4 lets a ticket keep its pictures as files, 4.2.5 adds identity providers, 4.2.6 keeps each ticket's email conversation together, 4.2.7 lets a reply from a CC say who sent it, 4.2.8 renames the watchers table for CCs, 4.2.9 lets the mail queue go at a pace your mail host takes, 4.3.0 lets contacts unsubscribe from bulk email, 4.3.1 encrypts the mail passwords and tokens, 4.3.2 keeps the email the ticket mailbox couldn't take, for your team to sort, and 4.3.3 adds Undo send and Reply-To for ticket emails. The client portal's Microsoft 365 single sign-on becomes the first identity provider, for client contacts, and keeps its redirect address, so nothing changes in Microsoft Entra. Nothing else is required: passkeys are on, and no one has one until they add it. Pictures already inside tickets move to files in the background afterwards - the new Ticket Pictures job in Maintenance > Cron does a batch a minute, so an install with years of emailed screenshots may take a while, and tickets work as usual meanwhile. A passkey is made for your ITFlow's address (the one in config.php) and only works there, over HTTPS - if you move ITFlow to a new address, everyone adds theirs again. Watchers are called CCs now. Emails about a ticket go to its contact with the CCs copied in, rather than one each - Admin > Settings > Tickets has the switch, under Emails about a ticket. On nginx, where ITFlow's .htaccess files aren't read, add `location ^~ /uploads/mail_unprocessed/ { deny all; }` beside the other private folders - it holds copies of the email kept for Unprocessed Email. Emailed and texted replies now wait 10 seconds on the ticket page, with Undo, before they go - Admin > Settings > Tickets sets how long, or turns it off. Ticket emails sent from another address than the mailbox ITFlow reads now ask for replies at that mailbox (Reply-To) - turn that off in the same place if the From address is an alias of that mailbox and you'd rather clients only saw it.
### Security
@@ -81,6 +81,8 @@ Update from Maintenance > Update as usual - this release has eleven database cha
- An agent who answers the client's email from their own mailbox - reply to all, with the support address copied in - has it on the ticket as their reply, not an internal note: the client has it, so it shows as emailed to them and counts as the ticket's first response, and the ticket is theirs when nobody had it, as a reply from the ticket does. Nothing more is sent. An email only to the support address is still their internal note.
- Unprocessed Email: email the ticket mailbox couldn't make a ticket from - someone who isn't a contact, at a domain no client has, while unknown senders aren't let in, or one that failed - is kept in Tickets > Unprocessed Email (in the menu beside New Ticket) and moved to the mailbox's ITFlow folder, where it used to stay in the inbox flagged and unread for someone to find. The tickets list says how many are waiting. Each shows who it is from, its subject, a line of what it says and why it wasn't taken.
- From Unprocessed Email an email can be opened (as text - nothing in it loads), made a ticket at the client you pick - for one of their contacts, or with the sender made a contact there first - added to a ticket, with the sender made a CC on it if you like, tried again (after making them a contact, say), dismissed, or downloaded as a .eml file. Try Again and Dismiss also work on several at once. The ticket or reply is made within a minute, as any email is, attachments and all, and the email shows which ticket it went on. Sorted and dismissed email is kept 30 days, and email nobody sorts 90.
+- Undo send: an emailed or texted reply waits a few seconds under the reply box - "Emailing it in 10 seconds" - with Undo and Send now. Undo leaves it in the reply box, as it was, to change or send later: nothing about it has happened yet - no email, no status change, no time added. Escape undoes it too, and leaving the page while it waits asks first. Admin > Settings > Tickets, Emails about a ticket, sets how long - 5, 10 (to start), 20 or 30 seconds - or turns it off. A public or internal note goes at once, as before.
+- Replies to ticket emails come back: an email about a ticket sent from another address than the mailbox ITFlow reads - a no-reply address, or one that isn't delivered there - asks for replies at that mailbox (Reply-To), where a client's reply used to go to the From address and be lost if nobody read it. Admin > Settings > Tickets says which addresses it uses, and turns it off for a From address that is an alias of the mailbox.
### Bug Fixes
@@ -163,6 +165,7 @@ Update from Maintenance > Update as usual - this release has eleven database cha
- Mail review stage 6: database 4.3.0 adds contacts.contact_unsubscribed_at and settings.config_mail_unsubscribe_secret. functions/contact_unsubscribe.php signs each contact's link with an HMAC of the contact id and address (contactUnsubscribeToken(), the key made on first use), and contactUnsubscribeSet() takes every contact with the address out or back in; contactUnsubscribedAddresses() is checked at send time, so a contact added since at another client is out too. guest/unsubscribe.php asks on GET, acts on its form's POST, and takes RFC 8058's List-Unsubscribe=One-Click POST with no page. emailBulkRecipients() (functions/email.php) builds the recipients from contact rows - the bounced, the unsubscribed, no address and the same address left out and counted - each with an unsubscribe link (emailHtml()'s new unsubscribe field) and its own List-Unsubscribe and List-Unsubscribe-Post headers (emailQueue() recipients' headers, let through by MAIL_QUEUE_HEADERS); emailBulkPost() now takes contact rows and converts Send at with timezoneFromView(). sendQueueEmail() sets the envelope sender per email - setFrom(..., false) with Sender reset, as PHPMailer's setFrom() kept the first email's From as Sender for the whole kept-alive connection - and for email_bulk passes mailQueueReturnPath(), the read mailbox when ticket parsing is on, the provider isn't Graph sending, the SMTP username is empty or that mailbox, and the domains align; a MAIL FROM refusal sends it again from the From address and sets mailQueueReturnPathRefused() for the run. mailQueueBouncesTo() tells the Email window.
- Mail review stage 7a: database 4.3.1 widens config_smtp_password, config_imap_password and config_mail_oauth_client_secret to varchar(500) and encrypts what is saved. functions/mail_secret.php seals MAIL_SECRET_COLUMNS (the two passwords, the OAuth secret, refresh and access tokens, and config_mail_graph_token) with secretSeal($plain, 'mail') as RMM and identity provider secrets are - but keeps a value as typed when there is no key, as mail would otherwise stop. mailSecretOpen() reads an unsealed value as it is, so nothing breaks before it is sealed: load_global_settings.php, cron/mail_queue.php, cron/nightly_tasks.php and mailGraphToken() open them; settingsWrite() seals secret-kind mail columns; every token write (the parser's two refreshes, persistMailOauthTokens(), the Microsoft callback, the Test OAuth refresh, mailGraphToken()) goes through mailSecretSql(). mailSecretsSealAll() runs in the update and nightly; mailSecretProblem() is the Admin > Settings > Mail warning. Remote pictures: ticketHtmlForAgents($purifier, $html) purifies and then ticketRemoteImagesHold() moves an http(s) or // img src to data-remote-src (a blank GIF and .itflow-remote-image in its place) and a style with a remote url() to data-remote-style - in agent/ticket.php, the quick look and ticketWorkOrderHtml(); ticketRemoteImagesNote() and js/app.js show the note and put them back. login.php drops the SMTP host, port, encryption, username and password it loaded but never used.
- Mail review stage 7b: database 4.3.2 adds email_unprocessed. functions/mail_unprocessed.php keeps an email the parser couldn't take - mailUnprocessedKeep($raw, $meta, $reason) writes its MIME to uploads/mail_unprocessed (denied to the web, as uploads/backups) and a row, one per Message-ID - and mailUnprocessedDecide() records an agent's ticket, reply, retry or dismiss (agent/email_unprocessed.php, agent/post/email_unprocessed.php). cron/ticket_email_parser.php appends mailUnprocessedAsked() to the run as MailUnprocessedMessage (functions/mail_unprocessed_message.php), a FileMessage whose move() is mailUnprocessedDone() with the ticket it went on and whose flags do nothing: a ticket or reply ask skips steps 1 to 6 for addTicket() at the chosen contact or client (or a new contact, as the domain match makes one) or addReply() on the chosen ticket (the sender added through ticketAddCcs() first, if asked); a retry goes the usual way. mailUnprocessedLeave() takes the unprocessed and exception branches - kept, then marked seen and moved to the ITFlow folder; flagged and unread as before when it can't be kept; an ask that fails waits again with the reason. mailUnprocessedCleanup() runs nightly.
+- Mail review stage 7c: database 4.3.3 adds settings.config_ticket_reply_undo_seconds (0, 5, 10, 20 or 30 - TICKET_REPLY_UNDO_CHOICES) and config_ticket_reply_to_read, read by ticketReplySendSettings() (functions/ticket_reply_send.php). Undo send is the ticket page alone: #ticketReplyForm's data-undo-seconds, and agent/js/ticket_reply_extras.js holds an emailed or texted reply's submit in a window listener - after the form's own checks and the canned response check on the document - with the reply card inert and the [data-reply-hold] bar, then requestSubmit()s it with holdOk, cannedSendAnyway and noTimeOk set; agent/post/ticket.php is unchanged. emailQueue() puts Reply-To (ticketMailReplyToRead(): email to ticket on, the setting on, the IMAP username an address and not From) in a thread email's headers; MAIL_QUEUE_HEADERS lets one bare address through and sendQueueEmail() gives it to addReplyTo(), so Graph's large-email draft carries it too.
## [26.12.2]
diff --git a/admin/database_updates/4.3.3.php b/admin/database_updates/4.3.3.php
new file mode 100644
index 000000000..39180764f
--- /dev/null
+++ b/admin/database_updates/4.3.3.php
@@ -0,0 +1,28 @@
+ Settings > Tickets:
+ * settings.config_ticket_reply_undo_seconds - how long an emailed or texted reply waits on the ticket page, with
+ * Undo, before it goes: 0 (at once), 5, 10, 20 or 30 seconds - 10 to start
+ * settings.config_ticket_reply_to_read - a ticket's email from another address than the mailbox ITFlow reads asks
+ * for replies at that mailbox (Reply-To) - on to start
+ *
+ * Re-runnable: each column is added only where it isn't there.
+ */
+
+defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
+
+ $itflow_reply_send_columns = [
+ ['config_ticket_reply_undo_seconds', "tinyint(3) NOT NULL DEFAULT 10 AFTER `config_ticket_email_relay`"],
+ ['config_ticket_reply_to_read', "tinyint(1) NOT NULL DEFAULT 1 AFTER `config_ticket_reply_undo_seconds`"],
+ ];
+ foreach ($itflow_reply_send_columns as [$itflow_column, $itflow_definition]) {
+ $itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'settings' AND COLUMN_NAME = '$itflow_column' LIMIT 1");
+ if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) {
+ mysqli_query($mysqli, "ALTER TABLE `settings` ADD `$itflow_column` $itflow_definition");
+ }
+ }
diff --git a/admin/post/settings_ticket.php b/admin/post/settings_ticket.php
index c04bfb97a..cb4a43394 100644
--- a/admin/post/settings_ticket.php
+++ b/admin/post/settings_ticket.php
@@ -2,7 +2,7 @@
/*
* Admin > Settings > Tickets (admin/settings_ticket.php):
- * edit_ticket_settings saves the numbering, email to ticket, the emails about a ticket, text to ticket, who hears of a
+ * edit_ticket_settings saves the numbering, email to ticket, the emails about a ticket (with undo send and Reply-To), text to ticket, who hears of a
* new ticket and whether AI triages it, whether the first agent to reply to an
* unassigned ticket is assigned it, what a quick ticket starts with, the timer
* and billing, the messages to clients, closing and the tickets page. A next
@@ -24,6 +24,7 @@ if (isset($_POST['edit_ticket_settings'])) {
'config_ticket_default_view', 'config_ticket_ordering', 'config_ticket_moving_columns'], aiTriageReady() ? ['config_ticket_ai_triage'] : [],
version_compare((string) CURRENT_DATABASE_VERSION, '4.0.9', '>=') ? ['config_ticket_reply_assigns'] : [],
ticketMailThreadReady() ? ['config_ticket_email_copy', 'config_ticket_email_relay'] : [],
+ ticketReplySendReady() ? ['config_ticket_reply_undo_seconds', 'config_ticket_reply_to_read'] : [],
settingsColumnExists($mysqli, 'config_ticket_sms_parse') ? ['config_ticket_sms_parse', 'config_ticket_sms_unknown_senders', 'config_ticket_sms_acknowledge'] : [],
ticketStatusReplyReady() ? ['config_ticket_assigned_message'] : [], ticketNoResponseReady() ? ['config_ticket_no_response_message'] : [],
quickTicketReady() ? ['config_quick_ticket_on', 'config_quick_ticket_assign', 'config_quick_ticket_status', 'config_quick_ticket_priority', 'config_quick_ticket_category',
@@ -54,6 +55,14 @@ if (isset($_POST['edit_ticket_settings'])) {
$after[$switch] = empty($_POST[$switch]) ? 0 : 1;
}
}
+ // Undo send and Reply-To - once the database has them (functions/ticket_reply_send.php)
+ if (array_key_exists('config_ticket_reply_to_read', $before)) {
+ $after['config_ticket_reply_to_read'] = empty($_POST['config_ticket_reply_to_read']) ? 0 : 1;
+ $after['config_ticket_reply_undo_seconds'] = intval($in['config_ticket_reply_undo_seconds']);
+ if (!isset(TICKET_REPLY_UNDO_CHOICES[$after['config_ticket_reply_undo_seconds']])) {
+ $errors['config_ticket_reply_undo_seconds'] = 'Pick how long from the list.';
+ }
+ }
// Text to ticket - once the database has it
if (array_key_exists('config_ticket_sms_parse', $before)) {
foreach (['config_ticket_sms_parse', 'config_ticket_sms_unknown_senders', 'config_ticket_sms_acknowledge'] as $switch) {
diff --git a/admin/settings_ticket.php b/admin/settings_ticket.php
index 8870a0c0a..28d009238 100644
--- a/admin/settings_ticket.php
+++ b/admin/settings_ticket.php
@@ -47,6 +47,21 @@ echo settingsPageStart('ticket');
= settingsSectionStart('emails', 'Emails about a ticket', 'Each has the subject [' . escapeHtml($config_ticket_prefix) . '123] Subject, the same from the first to the last, and carries the headers a mail program keeps a conversation together by - so they stay together in the client\'s inbox, and a reply finds its ticket even when its subject was changed.') ?>
= settingsSwitch('config_ticket_email_copy', $ticket_mail['copy'] ? 1 : 0, ['help' => 'An email about a ticket goes to its contact with the CCs, and the colleagues who asked for every update, copied in - everyone sees who else has it, and a reply to all reaches them. Off, each gets an email of their own.']) ?>
= settingsSwitch('config_ticket_email_relay', $ticket_mail['relay'] ? 1 : 0, ['help' => 'When the client replies - by email, text or in the portal - the people an agent\'s reply would go to get it too, with its files, unless it was already to them. By email, only a reply to one of the ticket\'s emails: anyone can put a ticket number in a subject.']) ?>
+ ' . escapeHtml($ticket_from) . ', the mailbox ITFlow reads.';
+ } else {
+ $reply_to_help = 'Ticket emails are from ' . escapeHtml($ticket_from ?: 'the system mailbox') . '. On, they ask for replies at ' . escapeHtml($reply_send['reads'])
+ . ', the mailbox ITFlow reads (Reply-To), so a reply isn\'t lost on an address nobody reads. Turn it off if ' . escapeHtml($ticket_from ?: 'that address') . ' already comes to that mailbox and you\'d rather clients only saw it.';
+ } ?>
+ = settingsSelect('config_ticket_reply_undo_seconds', ticketReplyUndoSeconds(), TICKET_REPLY_UNDO_CHOICES, ['icon' => 'fa-undo-alt',
+ 'help' => 'An emailed or texted reply waits this long on the ticket page, with Undo, before it goes - Undo leaves it in the reply box to change. Nothing about it happens until then.']) ?>
+ = settingsSwitch('config_ticket_reply_to_read', $reply_send['reply_to_read'] ? 1 : 0, ['help' => $reply_to_help]) ?>
+
= settingsSectionEnd() ?>
diff --git a/agent/js/ticket_reply_extras.js b/agent/js/ticket_reply_extras.js
index b0951efdd..d8df83774 100644
--- a/agent/js/ticket_reply_extras.js
+++ b/agent/js/ticket_reply_extras.js
@@ -9,6 +9,10 @@
* - +15m, +30m and +1h add to Time worked. The timer stops at the new total, as it does when the
* time is typed.
* - A reply with something in it and no time, on a billable ticket, asks first.
+ * - Undo send: an emailed or texted reply waits the form's data-undo-seconds (Admin > Settings > Tickets,
+ * functions/ticket_reply_send.php) under the reply box, locked, with Undo and Send now. Nothing is posted until then,
+ * so Undo leaves everything as it was, the reply still in the box and kept as a draft. Last of the checks: it holds
+ * only a reply nothing else held back, and lets it go with every check already answered.
*/
(function () {
'use strict';
@@ -353,4 +357,114 @@
} else {
form.addEventListener('submit', onSubmit);
}
+
+ // ---- Undo send
+
+ var holdSeconds = parseInt(form.dataset.undoSeconds || '0', 10) || 0;
+ var hold = form.querySelector('[data-reply-hold]');
+ var card = form.querySelector('.card');
+ var holding = null;
+
+ function replyType() {
+ var picked = form.querySelector('input[name="public_reply_type"]:checked');
+ return picked ? picked.value : '';
+ }
+
+ function stopHold() {
+ if (!holding) {
+ return null;
+ }
+ var submitter = holding.submitter;
+ clearInterval(holding.timer);
+ holding = null;
+ hold.hidden = true;
+ if (card) {
+ card.inert = false;
+ card.classList.remove('opacity-50');
+ }
+ return submitter;
+ }
+
+ // Go - every check before this one was answered on the way in, so none asks again
+ function release() {
+ var submitter = stopHold();
+ if (submitter === null) {
+ return;
+ }
+ form.dataset.holdOk = '1';
+ form.dataset.cannedSendAnyway = '1';
+ form.dataset.noTimeOk = '1';
+ if (typeof form.requestSubmit === 'function') {
+ form.requestSubmit(submitter);
+ } else {
+ form.submit();
+ }
+ }
+
+ function undo() {
+ if (stopHold() === null) {
+ return;
+ }
+ setStatus('Not sent - it is still here');
+ var ed = editor();
+ if (ed) {
+ ed.focus();
+ }
+ }
+
+ if (holdSeconds > 0 && hold) {
+ // On the window, so it hears the submit after the form's checks and the canned response check (on the document)
+ window.addEventListener('submit', function (e) {
+ if (e.target !== form) {
+ return;
+ }
+ // Already waiting - a second Send waits with it
+ if (holding) {
+ e.preventDefault();
+ return;
+ }
+ var let_go = form.dataset.holdOk === '1';
+ delete form.dataset.holdOk;
+ var type = replyType();
+ if (let_go || e.defaultPrevented || (type !== '2' && type !== '3') || !hasWords()) {
+ return;
+ }
+ e.preventDefault();
+ var left = holdSeconds;
+ var count = hold.querySelector('[data-reply-hold-count]');
+ hold.querySelector('[data-reply-hold-what]').textContent = type === '3' ? 'Texting it' : 'Emailing it';
+ count.textContent = left;
+ hold.hidden = false;
+ if (card) {
+ card.inert = true;
+ card.classList.add('opacity-50');
+ }
+ holding = {
+ submitter: e.submitter || form.querySelector('#ticket_add_reply'),
+ timer: setInterval(function () {
+ left -= 1;
+ count.textContent = Math.max(0, left);
+ if (left <= 0) {
+ release();
+ }
+ }, 1000)
+ };
+ hold.querySelector('[data-reply-hold-undo]').focus();
+ });
+ hold.querySelector('[data-reply-hold-undo]').addEventListener('click', undo);
+ hold.querySelector('[data-reply-hold-now]').addEventListener('click', release);
+ document.addEventListener('keydown', function (e) {
+ if (holding && e.key === 'Escape') {
+ e.preventDefault();
+ undo();
+ }
+ });
+ // Leaving now would lose the send - the draft is kept, but say so first
+ window.addEventListener('beforeunload', function (e) {
+ if (holding) {
+ e.preventDefault();
+ e.returnValue = '';
+ }
+ });
+ }
})();
diff --git a/agent/ticket.php b/agent/ticket.php
index 9a0484b75..446e504a0 100644
--- a/agent/ticket.php
+++ b/agent/ticket.php
@@ -861,7 +861,8 @@ if (isset($_GET['ticket_id'])) {
?>