I am building a new mailserver on Centos7. My sieve is created with: mkdir /home/sieve cat <<EOF>/home/sieve/globalfilter.sieve || exit 1 require "fileinto"; if exists "X-Spam-Flag" { if header :contains "X-Spam-Flag" "NO" { } else { fileinto "Spam"; stop; } } if header :contains "subject" ["***SPAM***"] { fileinto "Spam"; stop; } EOF chown -R vmail:mail /home/sieve But in 90-sieve.conf there is the comment: # A path to a global sieve script file, which gets executed ONLY # if user's private Sieve script doesn't exist. Be sure to # pre-compile this script manually using the sievec command line # tool. #sieve_global_path = /var/lib/dovecot/sieve/default.sieve Do I run sievec on this script? And I found the following comment on a blog, about 3 years old: 2: Having a user-defined sieve script will cancel out the global script for redirecting spam. In the dovecot.conf, get rid of the sieve_global_path and sieve_global_dir, and instead use: sieve_before = /path/to/global.sieve -- what this will do is make sure that the global script runs before any user scripts, which allows the spam redirecting to actually work. What is current situation on this? thank you
Op 3/16/2017 om 10:20 PM schreef Robert Moskowitz:> I am building a new mailserver on Centos7. > > My sieve is created with: > > mkdir /home/sieve > cat <<EOF>/home/sieve/globalfilter.sieve || exit 1 > require "fileinto"; > if exists "X-Spam-Flag" { > if header :contains "X-Spam-Flag" "NO" { > } else { > fileinto "Spam"; > stop; > } > } > if header :contains "subject" ["***SPAM***"] { > fileinto "Spam"; > stop; > } > EOF > > chown -R vmail:mail /home/sieve > > But in 90-sieve.conf there is the comment: > > # A path to a global sieve script file, which gets executed ONLY > # if user's private Sieve script doesn't exist. Be sure to > # pre-compile this script manually using the sievec command line > # tool. > #sieve_global_path = /var/lib/dovecot/sieve/default.sieve > > Do I run sievec on this script?Yes.> And I found the following comment on a blog, about 3 years old: > > 2: Having a user-defined sieve script will cancel out the global > script for redirecting spam. > In the dovecot.conf, get rid of the sieve_global_path and > sieve_global_dir, and instead > use: sieve_before = /path/to/global.sieve -- > what this will do is make sure that the global script runs before any > user scripts, > which allows the spam redirecting to actually work. > > What is current situation on this?That is usually good advice. The sieve_global_path setting is now called sieve_default, since it configures the default script for users that don't have a personal one. So, unless you want users to have the ability and necessity (!) to create their own spam handling rules once they create a personal script, use the sieve_before setting. The sieve_before script also needs to be pre-compiled with sievec. Regards, Stephan.
On 03/16/2017 03:58 PM, Stephan Bosch wrote:> Op 3/16/2017 om 10:20 PM schreef Robert Moskowitz: >> I am building a new mailserver on Centos7. >> >> My sieve is created with: >> >> mkdir /home/sieve >> cat <<EOF>/home/sieve/globalfilter.sieve || exit 1 >> require "fileinto"; >> if exists "X-Spam-Flag" { >> if header :contains "X-Spam-Flag" "NO" { >> } else { >> fileinto "Spam"; >> stop; >> } >> } >> if header :contains "subject" ["***SPAM***"] { >> fileinto "Spam"; >> stop; >> } >> EOF >> >> chown -R vmail:mail /home/sieve >> >> But in 90-sieve.conf there is the comment: >> >> # A path to a global sieve script file, which gets executed ONLY >> # if user's private Sieve script doesn't exist. Be sure to >> # pre-compile this script manually using the sievec command line >> # tool. >> #sieve_global_path = /var/lib/dovecot/sieve/default.sieve >> >> Do I run sievec on this script? > Yes. > >> And I found the following comment on a blog, about 3 years old: >> >> 2: Having a user-defined sieve script will cancel out the global >> script for redirecting spam. >> In the dovecot.conf, get rid of the sieve_global_path and >> sieve_global_dir, and instead >> use: sieve_before = /path/to/global.sieve -- >> what this will do is make sure that the global script runs before any >> user scripts, >> which allows the spam redirecting to actually work. >> >> What is current situation on this? > That is usually good advice. The sieve_global_path setting is now called > sieve_default, since it configures the default script for users that > don't have a personal one.And it is changes like this is why I am really trying for my notes to modify the provided files than replace them.> > So, unless you want users to have the ability and necessity (!) to > create their own spam handling rules once they create a personal script, > use the sieve_before setting. > > The sieve_before script also needs to be pre-compiled with sievec.It seems to my reading that this is the same global.sieve script as what I am using now. That you earlier told me I need to pre-compile. Or am I missing something?
Your pattern seems a little too complicated. See below. On 03/16/2017 02:20 PM, Robert Moskowitz wrote:> if exists "X-Spam-Flag" {This isn't needed. If the flag doesn't exist, the 'if header ...' line won't match. You're doing two tests for every message where one is all that's needed.> if header :contains "X-Spam-Flag" "NO" {You can just do "YES" here, and go straight to the command (fileinto). Yes/No is a boolean flag, it will either be one or the other.> fileinto "Spam"; > stop;It's not clear that you need the 'stop' here. hope this helps, Doug
Doug, On 03/16/2017 11:23 PM, Doug Barton wrote:> Your pattern seems a little too complicated. See below.I acquired this script from: http://www.campworld.net/thewiki/pmwiki.php/LinuxServersCentOS/Cent6VirtMailServer No telling where he got it from. So I greatly appreciate any and all advice. I am writing my own howto, and I would like to think I am doing a better job of it. I hope to have it finished in a couple weeks. I would say I am the proverbial 80% complete.> > On 03/16/2017 02:20 PM, Robert Moskowitz wrote: > >> if exists "X-Spam-Flag" { > > This isn't needed. If the flag doesn't exist, the 'if header ...' line > won't match. You're doing two tests for every message where one is all > that's needed. > >> if header :contains "X-Spam-Flag" "NO" { > > You can just do "YES" here, and go straight to the command (fileinto). > Yes/No is a boolean flag, it will either be one or the other. > >> fileinto "Spam"; >> stop; > > It's not clear that you need the 'stop' here. > > hope this helps,Not completely. I 'program' in English writing standards like IEEE 802.1AR, 802.15.9, and RFCs. I have not really programmed since the mid-80s with 'B'. I leave the converting of our carefully worded standards to executables to others.... :) That said, is this what you are advising: require "fileinto"; if header :contains "X-Spam-Flag" "YES" { } else { fileinto "Spam"; } if header :contains "subject" ["***SPAM***"] { fileinto "Spam"; } Thanks!