Mail review stage 8: Admin > Ignored Senders lists addresses and domains whose email the ticket mailbox sets aside with no ticket, reply, answer or Unprocessed Email entry, a domain taking its subdomains, each counting what it set aside and saving one that takes a contact's or client's email saying so; Ignore Sender in Unprocessed Email ignores the address or its domain and dismisses the others waiting, leaving contacts, client domains and public domains to an admin; Try an Email has the step; every queued email gets its own Message-ID and invoice and quote emails say what they are about, so a bounce marks the email it came back about as Bounced with the mail server's reason in a new Mail Queue tab, on the ticket reply for those it names and in the invoice or quote history, matched by address and subject when the report has no Message-ID; .gitignore leaves out uploads/mail_unprocessed and uploads/kb (database 4.3.5); 26.12.3 changelog

This commit is contained in:
johnnyq
2026-12-01 00:06:27 -05:00
parent 812c4ae9c2
commit d2d9732efb
31 changed files with 878 additions and 26 deletions

View File

@@ -0,0 +1,103 @@
<?php
/*
* Tickets > Unprocessed Email > Ignore Sender - its sender's address, or everyone at their domain, added to the ignored
* senders (functions/mail_ignore.php), so their email is set aside from now on; this email is dismissed, and the others
* waiting from them if asked. Not a domain anyone can have an address at (gmail.com), nor a client's - those are an
* admin's, in Admin > Ignored Senders. Saved by ignore_unprocessed_sender (agent/post/email_unprocessed.php).
*/
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_support', 2);
$row = mailUnprocessedReady() && mailIgnoreReady() ? mailUnprocessedRow($_GET['id'] ?? 0) : null;
$from = strtolower(trim((string) ($row['email_unprocessed_from_email'] ?? '')));
if (!$row || !filter_var($from, FILTER_VALIDATE_EMAIL)) {
echo json_encode(['error' => !$row ? "That email isn't there any more." : 'It has no sender address to ignore.']);
exit;
}
if (mailIgnoreReach($from)['contacts']) {
echo json_encode(['error' => "$from is a contact's address - an admin can ignore it, in Admin > Ignored Senders."]);
exit;
}
$id = intval($row['email_unprocessed_id']);
$domain = substr($from, strrpos($from, '@') + 1);
$domain_reach = mailIgnoreReach($domain);
// Why the domain can't be ignored from here, or ''
$domain_no = in_array($domain, EMAIL_PUBLIC_DOMAINS, true) ? "Anyone can have an address at $domain"
: ($domain_reach['clients'] ? 'It is the domain of ' . implode(', ', $domain_reach['clients']) . ' - an admin can, in Admin > Ignored Senders'
: ($domain_reach['contacts'] ? $domain_reach['contacts'] . ' contact' . ($domain_reach['contacts'] === 1 ? ' has an address' : 's have addresses') . ' there - an admin can, in Admin > Ignored Senders' : ''));
$waiting = function ($match) use ($mysqli) {
$count = 0;
$sql = mysqli_query($mysqli, "SELECT email_unprocessed_from_email FROM email_unprocessed WHERE email_unprocessed_done_at IS NULL AND email_unprocessed_action = ''");
while ($sql && ($other = mysqli_fetch_row($sql))) {
$count += mailIgnoreMatches($match, $other[0]) ? 1 : 0;
}
return $count;
};
$address_others = max(0, $waiting($from) - 1);
$domain_others = max(0, $waiting($domain) - 1);
$already = mailIgnoreFind($from);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-eye-slash me-2"></i>Ignore Sender</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="email_unprocessed_id" value="<?= $id ?>">
<div class="modal-body">
<p class="small text-body-secondary">From now on their email is set aside - no ticket, no answer, and nothing here to sort. Admin &gt; Ignored Senders lists who is ignored.</p>
<?php if ($already) { ?>
<div class="alert alert-info small py-2"><i class="fas fa-fw fa-info-circle me-1"></i><?= escapeHtml($already['ignored_sender_match']) ?> is ignored already - this email came before.</div>
<?php } ?>
<div class="mb-3" data-ignore-what>
<div class="form-check mb-2">
<input class="form-check-input" type="radio" name="ignore" value="address" id="ignoreAddress" checked>
<label class="form-check-label" for="ignoreAddress">
This address - <strong><?= escapeHtml($from) ?></strong>
<?php if ($address_others) { ?><span class="text-body-secondary small">(<?= $address_others ?> more waiting from it)</span><?php } ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="ignore" value="domain" id="ignoreDomain" <?= $domain_no !== '' ? 'disabled' : '' ?>>
<label class="form-check-label" for="ignoreDomain">
Everyone at <strong><?= escapeHtml($domain) ?></strong>
<?php if ($domain_no === '' && $domain_others) { ?><span class="text-body-secondary small">(<?= $domain_others ?> more waiting from there)</span><?php } ?>
</label>
<?php if ($domain_no !== '') { ?><div class="form-text" data-ignore-domain-no><?= escapeHtml($domain_no) ?></div><?php } ?>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="ignoreNote">Why</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-sticky-note"></i></span>
<input type="text" class="form-control" id="ignoreNote" name="ignored_sender_note" maxlength="255" placeholder="Newsletter, spam, a noisy system">
</div>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="dismiss_others" value="1" id="ignoreDismissOthers" checked>
<label class="form-check-label" for="ignoreDismissOthers">Dismiss the others waiting from them too</label>
<div class="form-text">This one is dismissed either way.</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="ignore_unprocessed_sender" class="btn btn-danger fw-bold"><i class="fas fa-eye-slash me-2"></i>Ignore</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -78,6 +78,9 @@ ob_start();
<button type="button" class="btn btn-outline-primary ajax-modal" data-modal-url="modals/email_unprocessed/email_unprocessed_reply.php?id=<?= $id ?>"><i class="fas fa-reply me-2"></i>Add to a Ticket</button>
<a class="btn btn-outline-secondary" href="post.php?unprocessed_email=retry&id=<?= $id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" title="As any email is taken - after making them a contact, say"><i class="fas fa-redo-alt me-2"></i>Try Again</a>
<a class="btn btn-outline-danger" href="post.php?unprocessed_email=dismiss&id=<?= $id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"><i class="fas fa-times me-2"></i>Dismiss</a>
<?php if (mailIgnoreReady() && filter_var(trim((string) $row['email_unprocessed_from_email']), FILTER_VALIDATE_EMAIL)) { ?>
<button type="button" class="btn btn-outline-danger ajax-modal" data-modal-url="modals/email_unprocessed/email_unprocessed_ignore.php?id=<?= $id ?>" title="Their email is set aside from now on"><i class="fas fa-eye-slash me-2"></i>Ignore Sender</button>
<?php } ?>
<?php } ?>
<?php if (!$email['missing']) { ?>
<a class="btn btn-light" href="post.php?download_unprocessed_email=<?= $id ?>"><i class="fas fa-download me-2"></i>Download</a>