mirror of
https://github.com/itflow-org/itflow
synced 2026-12-06 02:59:01 +00:00
Mail review stage 7c: emailed and texted replies wait a few seconds on the ticket page with Undo and Send now before they are posted, set in Admin > Settings > Tickets (database 4.3.3); ticket emails sent from another address than the mailbox ITFlow reads ask for replies at that mailbox with Reply-To, which can be turned off there; 26.12.3 changelog
This commit is contained in:
@@ -554,7 +554,9 @@ function emailInlineImages($html, array $ticket = []) {
|
||||
* update, which gives the queue somewhere to keep them, one each
|
||||
* thread the ticket whose conversation it is in - it gets a Message-ID of its own and
|
||||
* In-Reply-To and References naming the emails before it (ticketMailHeaders()),
|
||||
* and answering, the Message-ID of the email it answers, when it answers one
|
||||
* and answering, the Message-ID of the email it answers, when it answers one. From
|
||||
* another address than the mailbox ITFlow reads, it asks for replies there
|
||||
* (Reply-To, ticketMailReplyToRead())
|
||||
* auto replied (an automatic answer to an email) or generated (sent by ITFlow by
|
||||
* itself) - headers saying so, so it isn't answered (ticketMailAutoHeaders())
|
||||
* bulk an email to many - the contacts or clients list's Email - which the mail queue
|
||||
@@ -589,6 +591,8 @@ function emailQueue(array $recipients, $subject, array $email, array $opts = [])
|
||||
// Where the ticket's conversation stands as it is written - each email answers that
|
||||
$thread_id = intval($opts['thread'] ?? 0);
|
||||
$thread = $thread_id && ticketMailThreadReady() ? ticketMailThread($thread_id, (string) ($opts['answering'] ?? '')) : null;
|
||||
// Replies to the mailbox ITFlow reads, when it is sent from another address (functions/ticket_reply_send.php)
|
||||
$reply_to = $thread_id ? ticketMailReplyToRead((string) $from['email']) : '';
|
||||
$auto_headers = !empty($opts['auto']) ? ticketMailAutoHeaders((string) $opts['auto']) : [];
|
||||
|
||||
$sent = [];
|
||||
@@ -601,7 +605,8 @@ function emailQueue(array $recipients, $subject, array $email, array $opts = [])
|
||||
'name' => array_key_exists('greet', $recipient) ? $recipient['greet'] : $name,
|
||||
], $footnote !== null ? ['footnote' => $footnote] : [], !empty($recipient['unsubscribe']) && !$together ? ['unsubscribe' => (string) $recipient['unsubscribe']] : []));
|
||||
// Its own headers - a List-Unsubscribe for its link - with the conversation's and the automatic ones
|
||||
$headers = ($thread !== null ? ticketMailHeaders($thread_id, (string) $from['email'], $thread) : []) + $auto_headers + (!$together ? (array) ($recipient['headers'] ?? []) : []);
|
||||
$headers = ($thread !== null ? ticketMailHeaders($thread_id, (string) $from['email'], $thread) : []) + $auto_headers + (!$together ? (array) ($recipient['headers'] ?? []) : [])
|
||||
+ ($reply_to !== '' ? ['Reply-To' => $reply_to] : []);
|
||||
$went = [];
|
||||
foreach (array_merge([$recipient], $cc) as $person) {
|
||||
$went[strtolower($person['email'])] = $person['name'] !== '' ? $person['name'] . ' (' . $person['email'] . ')' : $person['email'];
|
||||
|
||||
@@ -526,6 +526,8 @@ const MAIL_QUEUE_HEADERS = [
|
||||
// Bulk email's link to leave, which mail programs show as their own Unsubscribe - one click (RFC 8058, functions/contact_unsubscribe.php)
|
||||
'List-Unsubscribe' => '/^<https:\/\/[^<>\s]+>$/',
|
||||
'List-Unsubscribe-Post' => '/^List-Unsubscribe=One-Click$/',
|
||||
// A ticket's email from another address than the mailbox ITFlow reads asks for replies there - one address (functions/ticket_reply_send.php)
|
||||
'Reply-To' => '/^[^<>\s@,;:"()\[\]\\\\]+@[^<>\s@,;:"()\[\]\\\\]+$/',
|
||||
];
|
||||
|
||||
/*
|
||||
|
||||
@@ -268,6 +268,10 @@ function settingsFields() {
|
||||
'words' => 'cc ccs copy copied watchers one email each separate recipients reply all'] + $on_off,
|
||||
'config_ticket_email_relay' => ['page' => 'ticket', 'section' => 'Emails about a ticket', 'label' => 'Pass a client\'s reply on to the CCs',
|
||||
'words' => 'relay forward client reply cc ccs watchers copied notify pass on'] + $on_off,
|
||||
'config_ticket_reply_undo_seconds' => ['page' => 'ticket', 'section' => 'Emails about a ticket', 'label' => 'Undo send', 'kind' => 'select', 'options' => TICKET_REPLY_UNDO_CHOICES,
|
||||
'words' => 'undo send delay hold back cancel recall unsend reply email text seconds'],
|
||||
'config_ticket_reply_to_read' => ['page' => 'ticket', 'section' => 'Emails about a ticket', 'label' => 'Replies come to the mailbox ITFlow reads',
|
||||
'words' => 'reply-to reply to replies mailbox read alias from address lost'] + $on_off,
|
||||
'config_ticket_sms_parse' => ['page' => 'ticket', 'section' => 'Text to ticket', 'label' => 'Turn texts into tickets', 'words' => 'text sms message mobile phone skyetel to ticket'] + $on_off,
|
||||
'config_ticket_sms_unknown_senders' => ['page' => 'ticket', 'section' => 'Text to ticket', 'label' => 'From unknown numbers too', 'words' => 'text sms unknown numbers anyone'] + $on_off,
|
||||
'config_ticket_sms_acknowledge' => ['page' => 'ticket', 'section' => 'Text to ticket', 'label' => 'Text back the ticket number', 'words' => 'text sms acknowledge reply confirm number'] + $on_off,
|
||||
|
||||
62
functions/ticket_reply_send.php
Normal file
62
functions/ticket_reply_send.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Sending an agent's reply - Admin > Settings > Tickets, Emails about a ticket (4.3.3):
|
||||
*
|
||||
* - Undo send: an emailed or texted reply waits config_ticket_reply_undo_seconds on the ticket page, with Undo, before
|
||||
* it is posted (agent/js/ticket_reply_extras.js) - Undo leaves it in the reply box, kept as a draft. Nothing reaches
|
||||
* the server until then, so there is nothing to take back: not the email, the status, the time or who it's assigned.
|
||||
* - Reply-To: an email in a ticket's conversation from an address other than the mailbox ITFlow reads asks for replies
|
||||
* at that mailbox (Reply-To), so a reply isn't lost on an address nobody reads - config_ticket_reply_to_read, on.
|
||||
*/
|
||||
|
||||
const TICKET_REPLY_UNDO_CHOICES = [0 => 'Off - send at once', 5 => '5 seconds', 10 => '10 seconds', 20 => '20 seconds', 30 => '30 seconds'];
|
||||
const TICKET_REPLY_UNDO_DEFAULT = 10;
|
||||
|
||||
/** Whether the 4.3.3 update has run - the settings are there. */
|
||||
function ticketReplySendReady() {
|
||||
global $mysqli;
|
||||
static $ready = null;
|
||||
if ($ready === null) {
|
||||
$version = defined('CURRENT_DATABASE_VERSION') ? CURRENT_DATABASE_VERSION
|
||||
: (string) (mysqli_fetch_row(mysqli_query($mysqli, "SELECT config_current_database_version FROM settings WHERE company_id = 1"))[0] ?? '0');
|
||||
$ready = version_compare($version, '4.3.3', '>=');
|
||||
}
|
||||
return $ready;
|
||||
}
|
||||
|
||||
/** ['undo' => seconds, 'reply_to_read' => bool, 'parse' => bool, 'reads' => the mailbox ITFlow reads, lower case, or ''] - as saved. */
|
||||
function ticketReplySendSettings() {
|
||||
global $mysqli;
|
||||
static $settings = null;
|
||||
if ($settings === null) {
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_ticket_email_parse, config_imap_provider, config_imap_username"
|
||||
. (ticketReplySendReady() ? ', config_ticket_reply_undo_seconds, config_ticket_reply_to_read' : '') . " FROM settings WHERE company_id = 1")) ?: [];
|
||||
$reads = strtolower(trim((string) ($row['config_imap_username'] ?? '')));
|
||||
$settings = [
|
||||
'undo' => intval($row['config_ticket_reply_undo_seconds'] ?? 0),
|
||||
'reply_to_read' => intval($row['config_ticket_reply_to_read'] ?? 0) === 1,
|
||||
'parse' => intval($row['config_ticket_email_parse'] ?? 0) === 1 && trim((string) ($row['config_imap_provider'] ?? '')) !== '',
|
||||
'reads' => filter_var($reads, FILTER_VALIDATE_EMAIL) ? $reads : '',
|
||||
];
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/** How long an emailed or texted reply waits on the ticket page, with Undo - 0 when it goes at once. */
|
||||
function ticketReplyUndoSeconds() {
|
||||
$seconds = ticketReplySendSettings()['undo'];
|
||||
return isset(TICKET_REPLY_UNDO_CHOICES[$seconds]) ? $seconds : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The address a ticket's email from $from_email asks replies to go to - the mailbox ITFlow reads, when email to ticket
|
||||
* is on, the setting is, and $from_email is another address - or '' for none, a reply going to From as always.
|
||||
*/
|
||||
function ticketMailReplyToRead($from_email) {
|
||||
$settings = ticketReplySendSettings();
|
||||
if (!$settings['parse'] || !$settings['reply_to_read'] || $settings['reads'] === '') {
|
||||
return '';
|
||||
}
|
||||
return $settings['reads'] !== strtolower(trim((string) $from_email)) ? $settings['reads'] : '';
|
||||
}
|
||||
Reference in New Issue
Block a user