Skip to content

Commit

Permalink
Honor per-user spam settings, fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyou committed Aug 18, 2016
1 parent 2a3f62f commit daf8c4b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
14 changes: 14 additions & 0 deletions dovecot/conf/pigeonhole-sieve.dict
@@ -1,5 +1,19 @@
connect = /data/freeposte.db

map {
pattern = priv/spam_enabled
table = user
username_field = email
value_field = spam_enabled
}

map {
pattern = priv/spam_threshold
table = user
username_field = email
value_field = spam_threshold
}

map {
pattern = priv/reply_enabled
table = user
Expand Down
14 changes: 10 additions & 4 deletions dovecot/sieve/after.sieve
@@ -1,6 +1,12 @@
require ["fileinto", "envelope", "mailbox", "imap4flags"];
require ["variables", "fileinto", "envelope", "mailbox", "imap4flags", "regex", "relational", "comparator-i;ascii-numeric", "vnd.dovecot.extdata"];

if header :contains "X-Spam" "YES" {
setflag "\\seen";
fileinto :create "Junk";

if string :is "${extdata.spam_enabled}" "1" {
if header :matches "X-Spam-Status" "* score=*" {
if string :value "ge" :comparator "i;ascii-numeric" "${2}" "${extdata.spam_threshold}" {
setflag "\\seen";
fileinto :create "Junk";
stop;
}
}
}
2 changes: 2 additions & 0 deletions rmilter/rmilter.conf
Expand Up @@ -59,6 +59,8 @@ spamd {
rspamd_metric = "default";
# Do not reject, add header
spamd_never_reject = yes;
# Add extended spam headers
extended_spam_headers = yes;
};

redis {
Expand Down

0 comments on commit daf8c4b

Please sign in to comment.