mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Clean up incoming ticket mail: a bounce is read first whatever the settings, marking the contacts it failed for and noting the ticket the email was about, found by the bounced email's Message-ID or subject, and never makes a ticket; only a mail server's own address or a bounce report counts, so an address with mta in it is a person; out-of-office replies are a note on the ticket they answer without reopening it or a notice; mail from systems and lists still makes tickets but is never answered; ITFlow's automatic emails carry Auto-Submitted and X-Auto-Response-Suppress, at most five an hour to one address; a watcher's or guest's reply is the client's reply, named by database 4.2.7, reopening the ticket and passed on; a near-same subject is a reply only from the ticket's contact or a watcher and otherwise a new ticket linked as related; a reply to a closed ticket is kept on it as a note and only contacts and watchers are told it is closed; Try an Email follows; 26.12.3 changelog entries
This commit is contained in:
@@ -306,18 +306,28 @@ function mailQueueCc($json) {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** The headers an email may carry (email_headers) - the ones that keep a conversation together, nothing else. */
|
||||
const MAIL_QUEUE_HEADERS = ['Message-ID', 'In-Reply-To', 'References'];
|
||||
/*
|
||||
* The headers an email may carry (email_headers), each with what its value must look like - the ones
|
||||
* that keep a conversation together, and the ones that say an email was sent by ITFlow itself
|
||||
* (ticketMailAutoHeaders()). Nothing else.
|
||||
*/
|
||||
const MAIL_QUEUE_HEADERS = [
|
||||
'Message-ID' => '/^<[^<>\s]+@[^<>\s]+>$/',
|
||||
'In-Reply-To' => '/^<[^<>\s]+@[^<>\s]+>$/',
|
||||
'References' => '/^(<[^<>\s]+@[^<>\s]+>)( <[^<>\s]+@[^<>\s]+>)*$/',
|
||||
'Auto-Submitted' => '/^auto-(replied|generated)$/',
|
||||
'X-Auto-Response-Suppress' => '/^[A-Za-z]+(, ?[A-Za-z]+)*$/',
|
||||
];
|
||||
|
||||
/*
|
||||
* An email's own headers (email_headers, emailQueue()'s thread) - [name => value] of those it may
|
||||
* carry (MAIL_QUEUE_HEADERS), each a list of <id@domain> and nothing else, on one line.
|
||||
* An email's own headers (email_headers, emailQueue()'s thread and auto) - [name => value] of those
|
||||
* it may carry (MAIL_QUEUE_HEADERS), each as it must look, on one line.
|
||||
*/
|
||||
function mailQueueHeaders($json) {
|
||||
$out = [];
|
||||
foreach ((array) json_decode((string) $json, true) as $name => $value) {
|
||||
$value = trim(preg_replace('/[\r\n\t ]+/', ' ', (string) $value));
|
||||
if (in_array($name, MAIL_QUEUE_HEADERS, true) && $value !== '' && strlen($value) <= 4000 && preg_match('/^(<[^<>\s]+@[^<>\s]+>)( <[^<>\s]+@[^<>\s]+>)*$/', $value)) {
|
||||
if (isset(MAIL_QUEUE_HEADERS[$name]) && $value !== '' && strlen($value) <= 4000 && preg_match(MAIL_QUEUE_HEADERS[$name], $value)) {
|
||||
$out[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user