Keep a ticket's emails in one conversation: every client email about a ticket has the subject [TCK-123] and its subject and carries Message-ID, In-Reply-To and References, kept per ticket in ticket_mail_threads, and the email parser finds a reply's ticket by those headers first, then by the number in brackets with the prefix that ticket was given; one email goes to the contact with the watchers and colleagues copied in, switchable in Admin, Settings, Tickets; a client's reply by email, text or portal is passed on to the people following the ticket who weren't on it, by email only when it answers one of the ticket's emails; others in To and Cc on a client's or watcher's email become watchers, never your own domain or agents; the same email twice makes one ticket and a merged ticket's replies go to the ticket it went into; database 4.2.6; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-30 13:08:24 -05:00
parent b208ed0069
commit 42ea7e58a5
27 changed files with 831 additions and 162 deletions

View File

@@ -853,8 +853,15 @@ function addToMailQueue($data) {
$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' : '';
// The people copied in, and the conversation's headers (emailQueue()'s together and thread) - once the 4.2.6 update has made the columns
$thread_sql = '';
if (ticketMailThreadReady()) {
// As they are - escapeSql() would take a Message-ID's <...> for a tag
$thread_sql = (!empty($email['cc']) ? ", email_cc = '" . mysqli_real_escape_string($mysqli, json_encode(array_values((array) $email['cc']), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) . "'" : '')
. (!empty($email['headers']) ? ", email_headers = '" . mysqli_real_escape_string($mysqli, json_encode((array) $email['headers'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) . "'" : '');
}
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");
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$thread_sql");
}
return true;