diff --git a/.gitignore b/.gitignore
index 983fe6552..d4e3f2729 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,11 @@ uploads/canned_responses/*
!uploads/canned_responses/.htaccess
uploads/quote_images/*
!uploads/quote_images/index.php
+uploads/kb/*
+!uploads/kb/index.php
+uploads/mail_unprocessed/*
+!uploads/mail_unprocessed/index.php
+!uploads/mail_unprocessed/.htaccess
.idea/*
libs/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/HTML/*
!libs/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/HTML/.gitkeep
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5ef33427..29c73f598 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 thirteen 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, 4.3.3 adds Undo send and Reply-To for ticket emails, and 4.3.4 lets the links in emails stop working once they're done with and keeps your own wording for the emails about a ticket. 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. The links in emails that open a ticket, an invoice or a quote without signing in now stop working 90 days after it is done - a ticket closed, an invoice paid, a quote answered or run out - so after the update, links to ones done longer ago than that no longer open them. The client portal still shows them, and Admin > Settings > Security sets how long, or keeps them working as before.
+Update from Maintenance > Update as usual - this release has fourteen 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, 4.3.3 adds Undo send and Reply-To for ticket emails, 4.3.4 lets the links in emails stop working once they're done with and keeps your own wording for the emails about a ticket, and 4.3.5 adds ignored senders and ties a bounce to the email that bounced. 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. The links in emails that open a ticket, an invoice or a quote without signing in now stop working 90 days after it is done - a ticket closed, an invoice paid, a quote answered or run out - so after the update, links to ones done longer ago than that no longer open them. The client portal still shows them, and Admin > Settings > Security sets how long, or keeps them working as before.
### Security
@@ -85,6 +85,9 @@ Update from Maintenance > Update as usual - this release has thirteen database c
- 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.
- Links in emails stop working once they're done with: the link that opens a ticket, an invoice or a quote without signing in - in its emails, forwarded on or kept for years - stops working 90 days after the ticket is closed, the invoice paid in full, or the quote accepted, declined, invoiced or run out. Open tickets, unpaid invoices and quotes waiting for an answer always work, a reopened ticket's link works again, and emailing an invoice or quote again counts from then. An expired link says so and points to the client portal, where they're shown as always. On an invoice or a quote, Copy Client Link says Expired once it has. Admin > Settings > Security, Links in emails, sets 30, 60, 90 (to start), 180 days or a year - or never, as before.
- Your own wording for the emails about a ticket to clients: Admin > Settings > Mail > Previews has Edit Wording on each of the 13 - ticket opened, their email became a ticket, scheduled ticket, reply, resolved, closed, a client's reply passed on, added as a CC, new ticket at their company, approval needed, work booked, booked work cancelled and replied to a closed ticket. Change its subject, heading, opening and closing text, with words in square brackets filled in as it goes, as in canned responses - [Ticket], [Subject], [First Name], [Client], [Agent], [Company] and each email's own, such as [By] and [When]. The preview shows it at once, the list marks the ones you changed, and Use ITFlow's Wording puts one back. The subject always starts with the ticket's number, so replies still find it.
+- Ignored senders: Admin > Ignored Senders lists the addresses and domains whose email the ticket mailbox sets aside - no ticket, no reply on one, no answer and nothing in Unprocessed Email. Newsletters, spam that gets through and noisy systems go straight to the mailbox's ITFlow folder. A domain takes its subdomains too, each shows how many emails it set aside and when the last came, and saving one that would set aside a contact's or a client's email says so. A mail server's bounce is still read, and Try an Email shows the step.
+- Ignore Sender in Unprocessed Email: ignore the address, or everyone at its domain, and dismiss the others waiting from them in one go. A contact's address, a client's domain or a domain anyone can have an address at (gmail.com) is left to an admin, in Admin > Ignored Senders.
+- Bounces come back to the email they were about: a reply on a ticket says "Email to ... bounced" with what the mail server said, where it said it was emailed, and an invoice's or quote's history says its email bounced. The Mail Queue has a Bounced tab, and the email's window shows the mail server's reason. Each email ITFlow sends now has its own Message-ID, so the bounce finds it - one sent before the update is found by its address and subject.
### Bug Fixes
@@ -169,6 +172,7 @@ Update from Maintenance > Update as usual - this release has thirteen database c
- 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.
- Mail review stage 7d: database 4.3.4 adds settings.config_guest_link_days (GUEST_LINK_DAYS_CHOICES, 90) and email_templates. functions/guest_link.php: guestLinkDoneAt() - ticket_closed_at; a Paid invoice's last unarchived payment (else its Paid history, else invoice_updated_at); an Accepted, Declined or Invoiced quote's history for it, or the end of quote_expire for one unanswered - later of that and the last history line with 'emailed' in it; guestLinkExpired() adds the days. ticketByGuestKey() returns null for an expired link, setting its new &$expired, so the guest ticket page, its attachments, its posts and its calendar file all refuse it; guest_view_invoice.php, guest_view_quote.php, the guest PDF exports (410) and the quote upload check it too, and guestLinkExpiredHtml() is the page; agent/invoice.php and agent/quote.php mark Copy Client Link Expired. functions/email_template.php: EMAIL_TEMPLATES (the 13 Tickets - to clients preview keys, with ITFlow's wording in placeholders), emailTemplateApply() replaces title, intro (paragraphs) and after where saved, filling [Placeholders] from emailTemplateValues() (ticketPlaceholderValues() and the email's own; empty when there is nothing), and puts the subject in template_subject for emailTemplateSubject(), which prefixes [REF] when it isn't in it. Applied in ticketEmailContent() (not the stranger's subject, nor Resolve - no response's intro), ticketMailSend(), ticketMailCcsAdded(), ticketMailColleaguesNew(), ticketMailTaskApproval() (the client's only) and ticketMailClosedReply(). admin/modals/email_template/email_template_edit.php and admin/post/email_template.php (save_email_template, reset_email_template - a part sent back as the default is NULL); mail_preview.php answers template and edited.
+- Mail review stage 8: database 4.3.5 adds email_ignored_senders and email_queue.email_message_id (indexed, filled in from email_headers), email_about, email_bounced_at and email_bounce. functions/mail_ignore.php: mailIgnoreClean() takes an address or a domain (@ or *@ in front allowed), mailIgnoreFind() matches the From address - an address rule before a domain one, a domain matching its subdomains - and cron/ticket_email_parser.php sets the email aside (seen, moved, mailIgnoreHit()) after the bounce check, unless it is a MailUnprocessedMessage asked to make a ticket or reply; ticketMailTry() has the step. Admin > Ignored Senders (admin/email_ignored_senders.php, modals/email_ignored_sender/, admin/post/email_ignored_sender.php); Unprocessed Email's ignore_unprocessed_sender refuses a contact's address, a client's domain and EMAIL_PUBLIC_DOMAINS, and mailIgnoreDismissWaiting() dismisses the rest. emailQueue() gives every email a Message-ID (emailMessageId()) where the conversation gave none and takes about (invoice:N, quote:N - billingEmailQueue()'s about, passed by every invoice and quote send); addToMailQueue() keeps both. addBounce() calls mailQueueBounced(): the sent row by email_message_id, else the last week's sent to a failed address with the bounce's subject, marked with {address: why}, and a billing email's history written. mailQueueStateOf() has bounced (status 3 with email_bounced_at), mailQueueTabs() a Bounced tab, ticketReplyEmailStates() marks each bounced recipient and the key bounced, and ticketReplyEmailHtml() says so. .gitignore leaves out uploads/mail_unprocessed and uploads/kb, as the other upload folders.
## [26.12.2]
diff --git a/admin/database_updates/4.3.5.php b/admin/database_updates/4.3.5.php
new file mode 100644
index 000000000..b44645a2a
--- /dev/null
+++ b/admin/database_updates/4.3.5.php
@@ -0,0 +1,58 @@
+ \t");
+ if ($itflow_message_id !== '' && strlen($itflow_message_id) <= 255) {
+ mysqli_query($mysqli, "UPDATE email_queue SET email_message_id = '" . mysqli_real_escape_string($mysqli, $itflow_message_id) . "' WHERE email_id = " . intval($itflow_queue_row['email_id']));
+ }
+ }
diff --git a/admin/email_ignored_senders.php b/admin/email_ignored_senders.php
new file mode 100644
index 000000000..5413979d3
--- /dev/null
+++ b/admin/email_ignored_senders.php
@@ -0,0 +1,136 @@
+ Ignored Senders - addresses and domains whose email the ticket mailbox sets aside (functions/mail_ignore.php):
+ * no ticket, no reply on one, no answer, no Unprocessed Email entry. Each with why, who added it, and how many emails it
+ * set aside and the last. New and edit in modals/email_ignored_sender/email_ignored_sender.php; the handlers are
+ * admin/post/email_ignored_sender.php. Unprocessed Email's Ignore Sender adds them too.
+ */
+
+// Default Column Sortby Filter
+$sort = "ignored_sender_match";
+$order = "ASC";
+
+require_once "includes/inc_all_admin.php";
+
+if (!mailIgnoreReady()) { ?>
+
+ "ignored_sender_match $order",
+ 'ignored_sender_matches' => "ignored_sender_matches $order, ignored_sender_match ASC",
+ 'ignored_sender_matched_at' => "ignored_sender_matched_at IS NULL, ignored_sender_matched_at $order, ignored_sender_match ASC",
+ 'ignored_sender_created_at' => "ignored_sender_created_at $order, ignored_sender_match ASC",
+];
+if (!isset($sortable_columns[$sort])) {
+ $sort = 'ignored_sender_match';
+}
+
+$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS email_ignored_senders.*, user_name FROM email_ignored_senders
+ LEFT JOIN users ON user_id = ignored_sender_created_by
+ WHERE (ignored_sender_match LIKE '%$q%' OR ignored_sender_note LIKE '%$q%')
+ ORDER BY {$sortable_columns[$sort]}
+ LIMIT $record_from, $record_to");
+$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
+
+?>
+
+
+
+
Ignored Senders
+
+
+
+
+
+
+
+ Email from these addresses and domains is set aside by the ticket mailbox: no ticket, no reply on one, and no answer - it is moved to the mailbox's
+ ITFlow folder like the rest. A domain takes its subdomains too. A mail server's bounce is still read, and an email an agent makes a ticket from in
+ Unprocessed Email goes where they say.
+