Cyrus/Sieve- Global Filter?

Ulrich Spoerlein uspoerlein at gmail.com
Sun Jul 15 05:04:20 EDT 2007


On Sat, 14.07.2007 at 17:16:53 +0100, George Cooke wrote:
> I just wonder as a shot in the dark how do most mail admins define global rules
> for filtering messages for every/user/certain groups of users, or is it up to
> the user to manage all filtering?

We have users that can hardly create their own mail filters, let alone
sieve filters. We therefore upload an initial sieve script into each
mailbox just after creation. It consists of only one rule: moving spam
into the Spam subfolder.

With the help of an expect(1) script this filter was initially uploaded
to all 150 accounts, or so.

It is so trivial, I'll attach it right here. You call it like this:
./sieve.expect cyrus cyrPASS uid host "put foo.script foo" "activate
foo"

#!/usr/local/bin/expect
# $Id: sieve.expect,v 1.1 2007/04/19 09:35:36 uspoerlein Exp $

set timeout 5

if {$argc<5} {
  send_user "usage: $argv0 auth pass user host cmd1 cmd2 ...\n"
  exit
}

set auth [lindex $argv 0]
set pass [lindex $argv 1]
set user [lindex $argv 2]
set host [lindex $argv 3]

spawn sieveshell -u $user -a $auth $host

expect "password: "
send "$pass\n"

for {set i 4} {$i<$argc} {incr i} {
  set cmd [lindex $argv $i]
  expect "> "
  send "$cmd\n"
}

expect "> "
send "quit\n"
expect eof

Don't run this on a shell-server though, as your cyrus admin password
will be visible from ps(1) output. 

Cheers,
Ulrich Spoerlein
-- 
"The trouble with the dictionary is you have to know how the word is
spelled before you can look it up to see how it is spelled."
-- Will Cuppy


More information about the Info-cyrus mailing list