mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 08:57:03 +03:00
Added spam score result for Bogosity
This commit is contained in:
parent
478ba00321
commit
6217d1cc49
3 changed files with 16 additions and 7 deletions
|
|
@ -156,6 +156,7 @@ class MailClient
|
||||||
// SPAM
|
// SPAM
|
||||||
\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS,
|
\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS,
|
||||||
\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT,
|
\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT,
|
||||||
|
\MailSo\Mime\Enumerations\Header::X_BOGOSITY
|
||||||
), true);
|
), true);
|
||||||
//
|
//
|
||||||
// return \MailSo\Imap\Enumerations\FetchType::ENVELOPE;
|
// return \MailSo\Imap\Enumerations\FetchType::ENVELOPE;
|
||||||
|
|
|
||||||
|
|
@ -532,15 +532,21 @@ class Message implements \JsonSerializable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT);
|
if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT)) {
|
||||||
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
||||||
if ($threshold = \floatval($match[2])) {
|
if ($threshold = \floatval($match[2])) {
|
||||||
$this->iSpamScore = \max(0, \min(100, 100 * \floatval($match[1]) / $threshold));
|
$this->iSpamScore = \max(0, \min(100, 100 * \floatval($match[1]) / $threshold));
|
||||||
$this->sSpamResult = "{$match[1]} / {$match[2]}";
|
$this->sSpamResult = "{$match[1]} / {$match[2]}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->bIsSpam = false !== \stripos($this->sSubject, '*** SPAM ***');
|
$this->bIsSpam = false !== \stripos($this->sSubject, '*** SPAM ***');
|
||||||
} else {
|
} else if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_BOGOSITY)) {
|
||||||
$spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS);
|
$this->sSpamResult = $spam;
|
||||||
|
$this->bIsSpam = !!\preg_match('/yes|spam/', $spam);
|
||||||
|
if (\preg_match('/spamicity=([\\d\\.]+)/', $spam, $spamicity)) {
|
||||||
|
$this->iSpamScore = \max(0, \min(100, \floatval($spamicity[1])));
|
||||||
|
}
|
||||||
|
} else if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS)) {
|
||||||
if (\preg_match('/(?:hits|score)=([\\d\\.-]+)/', $spam, $value)
|
if (\preg_match('/(?:hits|score)=([\\d\\.-]+)/', $spam, $value)
|
||||||
&& \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) {
|
&& \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) {
|
||||||
if ($threshold = \floatval($required[1])) {
|
if ($threshold = \floatval($required[1])) {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ abstract class Header
|
||||||
// Rspamd
|
// Rspamd
|
||||||
const X_SPAMD_RESULT = 'X-Spamd-Result'; // default: False [7.13 / 9.00];
|
const X_SPAMD_RESULT = 'X-Spamd-Result'; // default: False [7.13 / 9.00];
|
||||||
const X_SPAMD_BAR = 'X-Spamd-Bar'; // +++++++
|
const X_SPAMD_BAR = 'X-Spamd-Bar'; // +++++++
|
||||||
|
// Bogofilter
|
||||||
|
const X_BOGOSITY = 'X-Bogosity';
|
||||||
// Unknown
|
// Unknown
|
||||||
const X_SPAM_CATEGORY = 'X-Spam-Category'; // SPAM|LEGIT
|
const X_SPAM_CATEGORY = 'X-Spam-Category'; // SPAM|LEGIT
|
||||||
const X_SPAM_SCORE = 'X-Spam-Score'; // 0
|
const X_SPAM_SCORE = 'X-Spam-Score'; // 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue