Bayes classifier passing tests
This commit is contained in:
10
resources/config/sieve/bayes_classify.sieve
Normal file
10
resources/config/sieve/bayes_classify.sieve
Normal file
@@ -0,0 +1,10 @@
|
||||
if eval "!t.SPAM_TRAP && !t.TRUSTED_REPLY" {
|
||||
let "bayes_result" "bayes_classify('spamdb/bayes-classify', body_and_subject)";
|
||||
if eval "!is_empty(bayes_result)" {
|
||||
if eval "bayes_result > 0.7" {
|
||||
let "t.BAYES_SPAM" "1";
|
||||
} elsif eval "bayes_result < 0.5" {
|
||||
let "t.BAYES_HAM" "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ let "urls" "dedup(tokenize(header.subject, 'uri') + body_urls + html_body_urls)"
|
||||
|
||||
# Obtain thread name and subject
|
||||
let "subject_lc" "to_lowercase(header.subject)";
|
||||
let "thread_name" "thread_name(header.subject)";
|
||||
let "subject_clean" "thread_name(header.subject)";
|
||||
let "body_and_subject" "subject_clean + text_body";
|
||||
|
||||
# Obtain all recipients
|
||||
let "recipients" "to_lowercase(header.to:cc:bcc[*].addr[*])";
|
||||
|
||||
4
resources/config/sieve/replies_in.sieve
Normal file
4
resources/config/sieve/replies_in.sieve
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
if eval "lookup('spamdb/id-lookup', header.In-Reply-To:References)" {
|
||||
let "t.TRUSTED_REPLY" "1";
|
||||
}
|
||||
11
resources/config/sieve/replies_out.sieve
Normal file
11
resources/config/sieve/replies_out.sieve
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
# This script should be used on authenticated SMTP sessions only
|
||||
let "message_id" "header.Message-ID";
|
||||
|
||||
if eval "!is_empty(message_id)" {
|
||||
eval "lookup('spamdb/id-insert', message_id)";
|
||||
|
||||
if eval "lookup('spam/options', 'AUTOLEARN_REPLIES')" {
|
||||
eval "bayes_train('spamdb/bayes-train', thread_name(header.subject) + ' ' + body.to_text, false)";
|
||||
}
|
||||
}
|
||||
6
resources/config/sieve/spamtrap.sieve
Normal file
6
resources/config/sieve/spamtrap.sieve
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
# Check if the message was sent to a spam trap address
|
||||
if eval "lookup('spam/trap-address', envelope.to)" {
|
||||
eval "bayes_train('spamdb/bayes-train', body_and_subject, true)";
|
||||
let "t.SPAM_TRAP" "1";
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
let "raw_subject_lc" "to_lowercase(header.subject.raw)";
|
||||
let "is_ascii_subject" "is_ascii(subject_lc)";
|
||||
|
||||
if eval "len(thread_name) >= 10 && count(tokenize(thread_name, 'words')) > 1 && is_uppercase(thread_name)" {
|
||||
if eval "len(subject_clean) >= 10 && count(tokenize(subject_clean, 'words')) > 1 && is_uppercase(subject_clean)" {
|
||||
# Subject contains mostly capital letters
|
||||
let "t.SUBJ_ALL_CAPS" "1";
|
||||
}
|
||||
|
||||
if eval "count_chars(thread_name) > 200" {
|
||||
if eval "count_chars(subject_clean) > 200" {
|
||||
# Subject is very long
|
||||
let "t.LONG_SUBJ" "1";
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ ip-strategy = "ipv4-then-ipv6"
|
||||
dane = "optional"
|
||||
mta-sts = "optional"
|
||||
starttls = "require"
|
||||
allow-invalid-certs = false
|
||||
|
||||
#[queue.outbound.source-ip]
|
||||
#v4 = ["10.0.0.10", "10.0.0.11"]
|
||||
|
||||
Reference in New Issue
Block a user