[Dovecot] Writing "sieve" script

Steffen Kaiser skdovecot at smail.inf.fh-brs.de
Wed Mar 24 14:55:26 EET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 23 Mar 2010, Jerry wrote:

> require ["fileinto"];
> if header :contains "X-Virus-Status" "Infected" {fileinto "SPAM"; stop;}
> elsif header :contains "X-SpamCop-Disposition" "Blocked" {fileinto "SPAM"; stop;}
> elsif address :contains "To" "user1 at domain.com" {fileinto "INBOX.user1";}
> elsif address :contains "To" "user2 at domain.com" {fileinto "INBOX.user2";}
> elsif address :contains "To" "user3 at domain.com" {fileinto "INBOX.user3";}
> # The rest goes into INBOX
> # The default is "implicit keep", we do it here explicitly
> else {keep;}
>
> This works fine unless user1, user2 and or user3 are all included in
> the same e-mail address. It is rare; however, it does happen. In that
> case, a separate message for each recipient would be delivered to the
> first matching mailbox. The other recipients would not receive any traffic at all.

Is this a catch-all mail account so that a single account receives 
messages for user1, ...,& user3?

If so, you have a logical error in the program flow:

if user1 then
 	fileinto
else if user2 then
 	fileinto
else if ....
end if

when the first condition matches, the second will never tried.

hence:

if header :contains "X-Virus-Status" "Infected" {fileinto "SPAM"; stop;}
elsif header :contains "X-SpamCop-Disposition" "Blocked" {fileinto "SPAM"; stop;}
else {
 	if address :contains "To" "user1 at domain.com" {fileinto "INBOX.user1";}
 	if address :contains "To" "user2 at domain.com" {fileinto "INBOX.user2";}
 	if address :contains "To" "user3 at domain.com" {fileinto "INBOX.user3";}
 	# The rest goes into INBOX
}

if the implicit keep does not work, you need to add another "if", e.g.

 	if not address :contains "To" [ "user3 at domain.com", "user2 at domain.com","user1 at domain.com"] {
 		keep;
 	}

Regards,

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iQEVAwUBS6oLwL+Vh58GPL/cAQKTWwf/cPeaPmPh3yttL2kDlZf9H/aaAnmWYJ4j
FY4mc34XvhPyu3QaOlrlqFaSG9BPOlmo93nziCgTbt/g6V7PBGkUF0MLPGQXluKX
TbfjAilu5h4s0OKDLqO82YhhHuspQmvzLtPZ0HPfA8d66Bf6qfc57XO2ELremBBh
0kPvTyR9mPMvvXs/CuO7SEyh7Ng1bdzUzxntOMlcrwvEYF9miwX8HuFjtIYGXSMK
w3jtnxRZ6j4PpzE8716fLaQHMjivscWHq/CSX3JDwV547NDhVxzj2eWkRb99CT7N
MPYcEQHw/qj3VC9ro3tnsn1zvfyKpQ6R3ozSCkWeB7UKptWawMbKMQ==
=Uzfh
-----END PGP SIGNATURE-----


More information about the dovecot mailing list