mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
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:
@@ -193,6 +193,9 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<a class="dropdown-item" href="post.php?unprocessed_email=retry&id=<?= $id ?>&csrf_token=<?= $csrf ?>" title="As any email is taken - after making them a contact, say" data-unprocessed-retry><i class="fas fa-fw fa-redo-alt text-secondary me-2"></i>Try Again</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?unprocessed_email=dismiss&id=<?= $id ?>&csrf_token=<?= $csrf ?>" data-unprocessed-dismiss><i class="fas fa-fw fa-times text-secondary me-2"></i>Dismiss</a>
|
||||
<?php if (mailIgnoreReady() && filter_var($from_email, FILTER_VALIDATE_EMAIL)) { ?>
|
||||
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/email_unprocessed/email_unprocessed_ignore.php?id=<?= $id ?>" data-unprocessed-ignore><i class="fas fa-fw fa-eye-slash text-secondary me-2"></i>Ignore Sender</a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item" href="post.php?download_unprocessed_email=<?= $id ?>"><i class="fas fa-fw fa-download text-secondary me-2"></i>Download .eml</a>
|
||||
</div>
|
||||
|
||||
103
agent/modals/email_unprocessed/email_unprocessed_ignore.php
Normal file
103
agent/modals/email_unprocessed/email_unprocessed_ignore.php
Normal 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 > 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';
|
||||
@@ -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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* ITFlow - POST handlers for Tickets > Unprocessed Email (agent/email_unprocessed.php, functions/mail_unprocessed.php):
|
||||
* Make a Ticket, Add to a Ticket, Try Again and Dismiss - one at a time or Bulk Action - and Download .eml. A ticket, a
|
||||
* Make a Ticket, Add to a Ticket, Try Again and Dismiss - one at a time or Bulk Action - Ignore Sender, and Download .eml. A ticket, a
|
||||
* reply or a try again is asked of the email parser, which takes the email from its copy within a minute.
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,40 @@ if (isset($_POST['unprocessed_email_reply'])) {
|
||||
|
||||
}
|
||||
|
||||
// Ignore Sender - its address, or everyone at its domain, set aside from now on (functions/mail_ignore.php); this one
|
||||
// dismissed, and the others waiting from them if asked. Never a contact's address, a client's domain, or one anyone can
|
||||
// have an address at - those are an admin's, in Admin > Ignored Senders
|
||||
if (isset($_POST['ignore_unprocessed_sender'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$row = unprocessedEmailForRequest($_POST['email_unprocessed_id'] ?? 0);
|
||||
$from = strtolower(trim((string) $row['email_unprocessed_from_email']));
|
||||
if (!mailIgnoreReady() || !filter_var($from, FILTER_VALIDATE_EMAIL)) {
|
||||
flashAlert("That email has no sender address to ignore", 'error');
|
||||
redirect();
|
||||
}
|
||||
$domain = substr($from, strrpos($from, '@') + 1);
|
||||
$match = ($_POST['ignore'] ?? '') === 'domain' ? $domain : $from;
|
||||
$reach = mailIgnoreReach($match);
|
||||
if ($reach['contacts'] || $reach['clients'] || ($match === $domain && in_array($domain, EMAIL_PUBLIC_DOMAINS, true))) {
|
||||
flashAlert("<strong>" . escapeHtml($match) . "</strong> can't be ignored from here - " . ($reach['contacts'] || $reach['clients'] ? "it would set aside contacts' email" : "anyone can have an address there")
|
||||
. ". An admin can, in Admin > Ignored Senders", 'error');
|
||||
redirect();
|
||||
}
|
||||
|
||||
mailIgnoreAdd(mailIgnoreClean($match), trim((string) ($_POST['ignored_sender_note'] ?? '')) !== '' ? $_POST['ignored_sender_note'] : 'From Unprocessed Email', $session_user_id);
|
||||
mailUnprocessedDecide([$row['email_unprocessed_id']], 'dismiss', [], $session_user_id);
|
||||
$others = !empty($_POST['dismiss_others']) ? mailIgnoreDismissWaiting($match, $session_user_id) : 0;
|
||||
|
||||
logAudit("Email", "Unprocessed", "$session_name ignored email from " . escapeSql($match));
|
||||
flashAlert("Email from <strong>" . escapeHtml($match === $domain ? "@$domain" : $from) . "</strong> is set aside from now on" . ($others ? " - and $others more waiting from them dismissed" : ''));
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
// Try Again or Dismiss - one, from its menu
|
||||
if (isset($_GET['unprocessed_email'])) {
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ if (isset($_POST['email_invoice'])) {
|
||||
if ($kind === 'reminder' && $email['kind'] !== 'Payment reminder') {
|
||||
enforceUserPermission('module_sales', 2);
|
||||
}
|
||||
$sent = billingEmailQueue($recipients, $subject, $email, ['attach' => $attach]);
|
||||
$sent = billingEmailQueue($recipients, $subject, $email, ['attach' => $attach, 'about' => 'invoice:' . intval($invoice['invoice_id'])]);
|
||||
$reminder = $kind === 'reminder' && $email['kind'] === 'Payment reminder';
|
||||
// Texted with its link too, to those of them who agreed to texts (functions/sms.php)
|
||||
$texted = smsInvoiceNotify($invoice, $reminder ? 'reminder' : 'invoice', $recipients);
|
||||
|
||||
@@ -438,7 +438,7 @@ if (isset($_POST['email_quote'])) {
|
||||
if ($attach_pdf && ($file = billingEmailPdf(billingPdf('quote', $quote)))) {
|
||||
$attach[] = $file;
|
||||
}
|
||||
$sent = billingEmailQueue($recipients, $subject, $email, ['from' => 'quote', 'attach' => $attach]);
|
||||
$sent = billingEmailQueue($recipients, $subject, $email, ['from' => 'quote', 'attach' => $attach, 'about' => 'quote:' . intval($quote['quote_id'])]);
|
||||
|
||||
billingLog('quote', $quote_id, $quote['quote_status'] === 'Draft' ? 'Sent' : $quote['quote_status'], 'Quote emailed by ' . stripslashes($session_name) . ' to ' . implode(', ', $sent) . ($attach ? ' with the PDF' : ''));
|
||||
foreach ($recipients as $recipient) {
|
||||
|
||||
Reference in New Issue
Block a user