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,68 @@
<?php
/*
* New Ignored Sender, and Edit - an address or a domain whose email the ticket mailbox sets aside
* (functions/mail_ignore.php), and why. One that takes contacts' or a client's email says so here, and again on saving.
* Saved by add_ignored_sender and edit_ignored_sender (admin/post/email_ignored_sender.php).
*/
require_once '../../includes/modal_header.php';
if (!mailIgnoreReady()) {
echo json_encode(['error' => 'Ignored senders need the database update.']);
exit;
}
$id = intval($_GET['id'] ?? 0);
$row = $id ? mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT * FROM email_ignored_senders WHERE ignored_sender_id = $id")) : null;
if ($id && !$row) {
echo json_encode(['error' => "That ignored sender isn't there any more."]);
exit;
}
$match = (string) ($row['ignored_sender_match'] ?? '');
$reach = $row ? mailIgnoreReachText(mailIgnoreReach($match)) : '';
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-eye-slash me-2"></i><?= $row ? 'Ignored Sender' : 'New Ignored 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'] ?>">
<?php if ($row) { ?><input type="hidden" name="ignored_sender_id" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<?php if ($reach !== '') { ?>
<div class="alert alert-warning small py-2" data-ignored-reach><i class="fas fa-fw fa-exclamation-triangle me-1"></i><?= $reach ?></div>
<?php } ?>
<div class="mb-3">
<label class="form-label" for="ignoredSenderMatch">Address or domain <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-at"></i></span>
<input type="text" class="form-control" id="ignoredSenderMatch" name="ignored_sender_match" maxlength="255" required
value="<?= escapeHtml($match) ?>" placeholder="alerts@vendor.example, or vendor.example" <?= $row ? '' : 'autofocus' ?>>
</div>
<div class="form-text">An address sets aside only its email. A domain - <code>vendor.example</code> - sets aside everyone there, and at its subdomains.</div>
</div>
<div class="mb-3">
<label class="form-label" for="ignoredSenderNote">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="ignoredSenderNote" name="ignored_sender_note" maxlength="255"
value="<?= escapeHtml($row['ignored_sender_note'] ?? '') ?>" placeholder="Newsletter, spam, a noisy system">
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="<?= $row ? 'edit_ignored_sender' : 'add_ignored_sender' ?>" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i><?= $row ? 'Save' : '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

@@ -15,7 +15,7 @@ require_once '../../includes/modal_header.php';
$email_id = intval($_GET['id'] ?? 0);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT email_id, email_status, email_attempts, email_from, email_from_name, email_recipient, email_recipient_name, " . (ticketMailThreadReady() ? 'email_cc' : "'' AS email_cc") . ",
email_subject, email_content, email_content = '' AS email_cleared, email_cal_str, email_attachments, email_queued_at, email_failed_at, email_sent_at, " . mailQueueErrorColumn() . "
email_subject, email_content, email_content = '' AS email_cleared, email_cal_str, email_attachments, email_queued_at, email_failed_at, email_sent_at, " . mailQueueErrorColumn() . mailQueueBounceColumns() . "
FROM email_queue WHERE email_id = $email_id LIMIT 1"));
ob_start();
@@ -75,11 +75,11 @@ if (!$row) { ?>
</div>
<?php if ($state['error'] !== '') { ?>
<div class="alert <?= $state['key'] === 'cancelled' ? 'alert-secondary' : ($state['key'] === 'failed' ? 'alert-danger' : 'alert-warning') ?> py-2" data-email-error>
<div class="alert <?= $state['key'] === 'cancelled' ? 'alert-secondary' : (in_array($state['key'], ['failed', 'bounced'], true) ? 'alert-danger' : 'alert-warning') ?> py-2" data-email-error>
<?php if ($state['key'] === 'cancelled') { ?>
<i class="fas fa-fw fa-ban me-1"></i><?= escapeHtml($state['error']) ?>
<?php } else { ?>
<div class="small fw-semibold mb-1"><i class="fas fa-fw fa-exclamation-triangle me-1"></i>Why it failed</div>
<div class="small fw-semibold mb-1"><i class="fas fa-fw fa-exclamation-triangle me-1"></i><?= $state['key'] === 'bounced' ? 'It went, but came back - the mail server said' : 'Why it failed' ?></div>
<div class="small text-break font-monospace"><?= escapeHtml($state['error']) ?></div>
<?php } ?>
</div>