mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Mail review stage 8 follow-up: a bounce naming an address the email was not sent to (mail sent on to another mailbox) or naming nobody is the recipient's on an email to one person, saying where it came back from, and on an email to several marks nobody on it, keeps the named address and has the reply say a bounce came back and from where; an invoice's or quote's history gets one line for a bounce, not one for each report; Ignored Senders takes a domain with an international ending (xn--); mailIgnoreAdd returns the new id; Try an Email names the From unknown senders too switch and says to clear the flag on an email left in the inbox; 26.12.3 changelog
This commit is contained in:
@@ -1032,7 +1032,10 @@ function ticketReplyEmailed($reply_id, $emailed = true) {
|
||||
* and ticket_reply_emailed_to. Reply id => ['to' => [['email', 'name', 'state'
|
||||
* => mailQueueState(), or null once the queue has cleared it]], 'key' => sent,
|
||||
* waiting (still to go, or being tried again), failed, cancelled, or gone (the
|
||||
* queue no longer has them - kept 90 days)], for each reply emailed.
|
||||
* queue no longer has them - kept 90 days)], for each reply emailed. An email
|
||||
* that bounced for an address it wasn't sent to - someone's mail sent on - or
|
||||
* for nobody the report names, when it went to several (mailQueueBounced()):
|
||||
* 'elsewhere' => [address, or '' => why], and the key is bounced.
|
||||
*/
|
||||
function ticketReplyEmailStates(array $rows) {
|
||||
global $mysqli;
|
||||
@@ -1063,6 +1066,14 @@ function ticketReplyEmailStates(array $rows) {
|
||||
// Those copied in went, or didn't, with it
|
||||
$people = array_merge([['email' => (string) $email['email_recipient'], 'name' => (string) $email['email_recipient_name'] !== (string) $email['email_recipient'] ? (string) $email['email_recipient_name'] : '']],
|
||||
mailQueueCc($email['email_cc']));
|
||||
if ($state['key'] === 'bounced') {
|
||||
// For an address that isn't on it, or nobody it could name - which of them it was for can't be told
|
||||
$on_it = array_flip(array_map(function ($person) { return strtolower($person['email']); }, $people));
|
||||
$others = array_diff_key($state['bounce'], $on_it);
|
||||
if ($others || !array_intersect_key($state['bounce'], $on_it)) {
|
||||
$states[$reply_id]['elsewhere'] = ($states[$reply_id]['elsewhere'] ?? []) + array_map('mailQueueErrorText', $others ?: ['' => '']);
|
||||
}
|
||||
}
|
||||
foreach ($people as $person) {
|
||||
$address = strtolower($person['email']);
|
||||
$person_state = $state;
|
||||
@@ -1091,7 +1102,8 @@ function ticketReplyEmailStates(array $rows) {
|
||||
} else {
|
||||
$key = 'sent';
|
||||
}
|
||||
$states[$reply_id] = ['to' => array_values($state['to']), 'key' => $key];
|
||||
$elsewhere = (array) ($state['elsewhere'] ?? []);
|
||||
$states[$reply_id] = ['to' => array_values($state['to']), 'key' => $key === 'sent' && $elsewhere ? 'bounced' : $key] + ($elsewhere ? ['elsewhere' => $elsewhere] : []);
|
||||
}
|
||||
return $states;
|
||||
}
|
||||
@@ -1873,7 +1885,7 @@ function ticketReplyEmailHtml($reply_id, array $state, $queue_url = '') {
|
||||
break;
|
||||
case 'bounced':
|
||||
[$icon, $text, $title] = ['fa-reply text-danger', $bounced === count($to) ? "<span class=\"text-danger\">Email to $first bounced</span>"
|
||||
: "Emailed to $first <span class=\"text-danger\">· $bounced bounced</span>", 'Bounced'];
|
||||
: "Emailed to $first <span class=\"text-danger\">· " . ($bounced ? "$bounced bounced" : 'a bounce came back') . "</span>", 'Bounced'];
|
||||
break;
|
||||
default:
|
||||
[$icon, $text, $title] = ['fa-paper-plane', "Emailed to $first", ''];
|
||||
@@ -1894,9 +1906,16 @@ function ticketReplyEmailHtml($reply_id, array $state, $queue_url = '') {
|
||||
. '</li>';
|
||||
}
|
||||
$gone = !array_filter(array_column($to, 'state'));
|
||||
// It came back for an address it wasn't sent to, or for nobody it named (ticketReplyEmailStates())
|
||||
$elsewhere = '';
|
||||
foreach ((array) ($state['elsewhere'] ?? []) as $address => $why) {
|
||||
$elsewhere .= '<div class="text-danger mt-1" data-reply-bounced-elsewhere>' . ((string) $address !== ''
|
||||
? 'It came back from <strong class="text-break">' . escapeHtml($address) . '</strong>, which it wasn\'t sent to - one of them has their mail sent on there' . ((string) $why !== '' ? ': ' . escapeHtml($why) : '.')
|
||||
: 'A bounce came back for this email that doesn\'t say who it couldn\'t reach.') . '</div>';
|
||||
}
|
||||
$panel = '<div class="collapse" id="replyEmailed' . $reply_id . '">'
|
||||
. '<div class="ticket-reply-recipients small mt-2">'
|
||||
. '<ul class="list-unstyled d-grid gap-1 mb-0">' . $items . '</ul>'
|
||||
. '<ul class="list-unstyled d-grid gap-1 mb-0">' . $items . '</ul>' . $elsewhere
|
||||
. ($gone ? '<div class="text-body-secondary mt-1">The mail queue keeps email ' . MAIL_QUEUE_KEEP_DAYS . ' days, so whether each one went is no longer known.</div>' : '')
|
||||
. ($queue_url !== '' ? '<a class="d-inline-block mt-1" href="' . escapeHtml($queue_url) . '"><i class="fas fa-fw fa-mail-bulk me-1"></i>This ticket\'s email in the Mail Queue</a>' : '')
|
||||
. '</div></div>';
|
||||
|
||||
Reference in New Issue
Block a user