mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-21 14:22:23 +08: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
|
||||
\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS,
|
||||
\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT,
|
||||
\MailSo\Mime\Enumerations\Header::X_BOGOSITY
|
||||
), true);
|
||||
//
|
||||
// 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 (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
||||
if ($threshold = \floatval($match[2])) {
|
||||
$this->iSpamScore = \max(0, \min(100, 100 * \floatval($match[1]) / $threshold));
|
||||
$this->sSpamResult = "{$match[1]} / {$match[2]}";
|
||||
if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT)) {
|
||||
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
||||
if ($threshold = \floatval($match[2])) {
|
||||
$this->iSpamScore = \max(0, \min(100, 100 * \floatval($match[1]) / $threshold));
|
||||
$this->sSpamResult = "{$match[1]} / {$match[2]}";
|
||||
}
|
||||
}
|
||||
$this->bIsSpam = false !== \stripos($this->sSubject, '*** SPAM ***');
|
||||
} else {
|
||||
$spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS);
|
||||
} else if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_BOGOSITY)) {
|
||||
$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)
|
||||
&& \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) {
|
||||
if ($threshold = \floatval($required[1])) {
|
||||
|
|
|
@ -61,6 +61,8 @@ abstract class Header
|
|||
// Rspamd
|
||||
const X_SPAMD_RESULT = 'X-Spamd-Result'; // default: False [7.13 / 9.00];
|
||||
const X_SPAMD_BAR = 'X-Spamd-Bar'; // +++++++
|
||||
// Bogofilter
|
||||
const X_BOGOSITY = 'X-Bogosity';
|
||||
// Unknown
|
||||
const X_SPAM_CATEGORY = 'X-Spam-Category'; // SPAM|LEGIT
|
||||
const X_SPAM_SCORE = 'X-Spam-Score'; // 0
|
||||
|
|
Loading…
Reference in a new issue