Commit 7f6feb10 authored by Claudemir Todo Bom's avatar Claudemir Todo Bom

* new spam/ham learning method using imapsieve ( https://docs.iredmail.org/dovecot.imapsieve.html )

parent 84f21f87
Pipeline #189 passed with stage
in 1 minute and 18 seconds
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-pipe.sh" [ "${username}", "ham" ];
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-pipe.sh" [ "${username}", "spam" ];
......@@ -14,23 +14,8 @@ cat - > ${TEMPFILE}
&& [ -d /proc/${SAQ_PID} ] && grep -q sa-learn-queue.sh /proc/${SAQ_PID}/cmdline
) || /usr/bin/sudo -u root /usr/local/bin/sa-learn-runqueue.sh
while [ $1 ] ; do
case $1 in
--spam)
SACOMMAND=--spam
;;
--ham)
SACOMMAND=--ham
;;
-u)
shift
SAUSER=$1
;;
esac
shift
done
SAUSER="$1"
SACOMMAND="--$2"
[ -e /var/spool/maildir/salearn.pipe ] || ( /usr/bin/mkfifo /var/spool/maildir/salearn.pipe && /bin/chmod ugo+r /var/spool/maildir/salearn.pipe )
......
......@@ -116,6 +116,11 @@ cp lighttpd/conf-enabled/* /etc/lighttpd/conf-enabled/
cp roundcube/* /etc/roundcube/
cp -a www /var/www/html/wwmail
cp -a userapi /var/www/html/userapi
cp -a antispamsieve /etc/wwmail/antispamsieve
chown mail.mail /etc/wwmail/antispamsieve -R
chmod 0700 /etc/wwmail/antispamsieve -R
sievec /etc/wwmail/antispamsieve/learn_ham.sieve
sievec /etc/wwmail/antispamsieve/learn_spam.sieve
```
Os usuário e grupo `clamav` precisam ser ajustados para se integrar corretamente com o `exim`, para isso devem ser utilizados os seguintes comandos:
......
......@@ -5,6 +5,7 @@ log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:%h
mail_privileged_group = mail
mail_plugins = quota
mail_attribute_dict = file:%h/dovecot-attributes
imap_capability = +SPECIAL-USE
......@@ -19,13 +20,22 @@ plugin {
quota_rule3 = Spam:ignore
quota_rule4 = Junk:ignore
antispam_backend = pipe
antispam_trash = trash;Trash;Deleted Items; Deleted Messages
antispam_spam = SPAM;Spam;Junk;Junk E-mail
antispam_pipe_program = /usr/local/bin/sa-learn-pipe.sh
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg = --ham
antispam_pipe_program_args = -u;%u
sieve_plugins = sieve_imapsieve sieve_extprograms
# From elsewhere to Junk folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY APPEND
imapsieve_mailbox1_before = file:/etc/wwmail/antispamsieve/learn_spam.sieve
# From Junk folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/etc/wwmail/antispamsieve/learn_ham.sieve
sieve_pipe_bin_dir = /etc/wwmail/antispamsieve/
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
}
protocols = imap pop3 lmtp sieve
......@@ -77,7 +87,7 @@ userdb {
driver = sql
}
protocol imap {
mail_plugins = quota imap_quota antispam
mail_plugins = quota imap_quota imap_sieve
}
protocol pop3 {
mail_plugins = quota lazy_expunge
......@@ -146,13 +156,3 @@ protocol lda {
protocol lmtp {
mail_plugins = $mail_plugins sieve
}
service stats {
unix_listener stats-reader {
group = mail
mode = 0660
}
unix_listener stats-writer {
group = mail
mode = 0660
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment