[Dovecot] global sieve script
hi all,
i'm moving from a maildrop+courier setup to lda(sieve)+dovecot setup.
with maildrop i had a global filter for all the users, so i could filter and archive into the spam folder spam tagged emails for users without custom filters, including them if they exist:
LOGNAME=tolower($LOGNAME)
test -e $LOGNAME
if ( $RETURNCODE != 0 )
{
maildirmake $LOGNAME
maildirmake $LOGNAME/._spam
}
test -f $LOGNAME/mailfilter
if ( $RETURNCODE == 0 )
{
include "$LOGNAME/mailfilter"
}
if ( /^X-Spam-Status: YES */) { to "$LOGNAME/._spam" } else { to "$LOGNAME/" }
how could i get this behaviour with dovecot lda and sieve ?
thanks !
Jorge Salamero Sanz wrote:
hi all,
i'm moving from a maildrop+courier setup to lda(sieve)+dovecot setup.
with maildrop i had a global filter for all the users, so i could filter and archive into the spam folder spam tagged emails for users without custom filters, including them if they exist:
LOGNAME=tolower($LOGNAME)
test -e $LOGNAME
if ( $RETURNCODE != 0 ) {maildirmake $LOGNAME
maildirmake $LOGNAME/._spam
}
test -f $LOGNAME/mailfilter
if ( $RETURNCODE == 0 ) { include "$LOGNAME/mailfilter" }if ( /^X-Spam-Status: YES */) { to "$LOGNAME/._spam" } else { to "$LOGNAME/" }
how could i get this behaviour with dovecot lda and sieve ?
For example:
/etc/dovecot/dovecot.conf: ... protocol lda { ... sieve_global_path = /etc/dovecot/sieve/ ... }
/etc/dovecot/global: if header :contains "X-Spam-Flag" "YES" { fileinto "Spam"; stop; }
...or something similar. /L
"LS" == Lars Stavholm stava@telcotec.se writes:
LS> For example:
LS> /etc/dovecot/dovecot.conf:
LS> ...
LS> protocol lda {
LS> ...
LS> sieve_global_path = /etc/dovecot/sieve/
LS> ...
LS> }
LS> /etc/dovecot/global:
LS> if header :contains "X-Spam-Flag" "YES" {
LS> fileinto "Spam";
LS> stop;
LS> }
LS> ...or something similar.
Definitely take the "something similar" option since the above likely won't work.
sieve_global_path should point to a _file_ containing a sieve script and both the script _and_ the byte-compiled version (same name with 'c' appended) should exist and the compiled output file should have an mtime later than the source. If the cmusieve plugin can't find the compiled version (or the mtime of the source is later than the mtime of the compiled version) it will attempt to write it out a compiled version and filesystem permissions really ought to prevent that.
So
/etc/dovecot/dovecot.conf: ... protocol lda { ... sieve_global_path = /etc/dovecot/global.sieve ... }
/etc/dovecot/global.sieve: if header :contains "X-Spam-Flag" "YES" { fileinto "Spam"; stop; }
AND remember to byte-compile the script
/usr/libexec/dovecot/sievec /etc/dovecot/global.sieve /etc/dovecot/global.sievec
participants (3)
-
Jorge Salamero Sanz
-
Lars Stavholm
-
pod