View Single Post
  #7 (permalink)  
Old 02-28-2007, 06:35 PM
dlbewley dlbewley is offline
Senior Member
 
Posts: 61
Post using zmprov to set mail filter sieve scripts

My rules didn't comply for that conversion script, but once you have your rules converted, below is a way to stick them into Zimbra.

Create a file like the following and pipe it to zmprov. Note that the newlines inside the value for zimbraMailSieveScript must be escaped:
Code:
ma jdoe zimbraMailSieveScript '\
require ["fileinto", "reject", "tag", "flag"];\
# Helpdesk Tickets\
if anyof (header :contains "subject" "[Lib Help #" )\
{\
    tag "Tickets";\
    flag "flagged";\
    stop;\
}\
'
Maybe you have a filter you want to pre-populate for a set of workstation support people. Create a file with your filters in it, like this call it filters.tmpl:
Code:
require ["fileinto", "reject", "tag", "flag"];\
# Helpdesk Tickets\
if anyof (header :contains "subject" "[Lib Help #" )\
{\
    tag "Tickets";\
    flag "flagged";\
    stop;\
}\
Then you can pre-populate users' filters like this:
Code:
 cat users.txt | while read user; do
     echo "ma $user zimbraMailSieveScript '\\" >> filters.zmp
     cat filters.tmpl >> filters.zmp
     echo "'" >> filters.zmp
 done
Now pipe filters.zmp to zmprov.

If you have tags in your filters like my example, you'll need to pre-create those. Put them in a file called tags.tmpl (one per line) and do this.
Code:
 cat users.txt | while read user; do
    echo "sm $user" >> tags.zmp
    cat tags.tmpl | while read tag; do
         echo "createTag '$tag'" >> tags.zmp
     done
     echo "exit" >> tags.zmp 
done
Now pipe tags.zmp to zmprov. Note, you should create the tags before the filters.

Last edited by dlbewley; 02-28-2007 at 06:41 PM.. Reason: fix logic error in tags script
Reply With Quote