2
0
forked from Wavyzz/dolibarr

Fix reply-to filter for email collector (#30152)

Co-authored-by: Hystepik <lmarcouiller@nltechno.com>
This commit is contained in:
Lucas Marcouiller
2024-06-25 15:19:26 +02:00
committed by GitHub
parent bd2a0b9e55
commit 32ea86c62f

View File

@@ -1104,6 +1104,7 @@ class EmailCollector extends CommonObject
$searchfilterexcludebodyarray = array();
$searchfilterexcludesubjectarray = array();
$operationslog = '';
$rulesreplyto = array();
$now = dol_now();
@@ -1390,6 +1391,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'replyto') {
$searchfilterreplyto++;
$rulesreplyto[] = $rule['rulevalue'];
$searchhead .= '/Reply-To.*'.preg_quote($rule['rulevalue'], '/').'/';
}
}
@@ -1531,6 +1533,7 @@ class EmailCollector extends CommonObject
if ($rule['type'] == 'replyto') {
$searchfilterreplyto++;
$rulesreplyto[] = $rule['rulevalue'];
$searchhead .= '/Reply-To.*'.preg_quote($rule['rulevalue'], '/').'/';
}
}
@@ -1763,6 +1766,22 @@ class EmailCollector extends CommonObject
}
}
}
if ($searchfilterreplyto > 0) {
if (!empty($headers['Reply-To'])) {
$isreplytook = 0;
foreach ($rulesreplyto as $key => $rulereplyto) {
if (preg_match('/'.preg_quote($rulereplyto, '/').'/', $headers['Reply-To'])) {
$isreplytook ++;
}
}
if (!$isreplytook || $isreplytook != count($rulesreplyto)) {
$nbemailprocessed++;
dol_syslog(" Discarded - Reply-to does not match");
continue; // Exclude email
}
}
}
//print "Process mail ".$iforemailloop." Subject: ".dol_escape_htmltag($headers['Subject'])." selected<br>\n";