/* Example: "classify" This example demonstrates some ways to classify and deal with messages. */ sieve { /* Open the sieve block */ /* Enable some of the extended capabilities used in this script. */ require [ "fileinto", "reject", "copy", "envelope" ]; require [ "relational", "comparator-i;ascii-numeric" ]; /* Discard mail that has more than 50 listed recipients. */ if address :comparator "i;ascii-numeric" :count "gt" ["to", "cc"] "50" { discard; } /* Mail larger than 1MB is not wanted. Note: this uses "reject" -- in reality, don't use reject unless you are absolutely sure you are returning mail to the correct sender. It's just way too easy to be fooled into replying to an innocent bystander to do this as a general matter. */ elsif size :over 1m { reject "Huge mail not wanted. Please put your data on a web page and send me the URL."; } /* We run qmail, so any address user@example.com can have extensions like user-test1@example.com . Let's say we've given out an extension of "-projectx" -- we want to forward mail using that address to another location. The :copy flag causes "implicit keep" not to be turned off -- meaning that we still get a copy in our inbox. */ elsif envelope :is :localpart "to" "user-projectx" { redirect :copy "myotheraddress@example.net"; } /* Lets say we have given out so many extension addresses we can't file them all in the same box. File -a* through -m* in one box, and everything else in another. Note the nested "if" statements. It's unlikely anyone would do this, but this IS an example.. */ elsif envelope :matches :localpart "to" "user-*" { if allof ( envelope :localpart :value "ge" "to" "user-a", envelope :localpart :value "le" "to" "user-m" ) { fileinto "ext a-m"; } else { fileinto "ext other"; } } /* Let "implicit keep" deal with mail not otherwise filtered. */ }