Email Rules Migration



Note: The ZCS Connector doesn't migrate outlook 2003 mail rules, IIRC from a 200 user migration I did in the past (gettyless 4/26/2009)



You have a few options to migrate Sieve rules. Generally you can take existing rules and then just dump them into the account attribute zimbraMailSieveScript. The server will be able to process these rules. However, if you intend to enable the client to edit the rules you will need to make sure they conform to a ZCS-specific set of characteristics. There are two ways to do this.

Using zmmailbox addFilterRule

Within the zmmailbox command there is a "addFilterRule" command. This allows you to add a named filter to a particular user. Its usage defines the parameters that ZWC can understand for editing. Given that for any migration scenario you'll likely end up parsing the rules, this will let you reconstruct the rules in a syntax ZWC understands. You will need to find a "name" for each rule. It could be as simple as "rule1", "rule2", etc.

Here's the usage for addFilterRule [zimbra@qa03 ~]$ zmmailbox help filter

 addFilterRule(afrl)                    add filter rule
 deleteFilterRule(dfrl)                 add filter rule
 getFilterRules(gfrl)                   get filter rules
 modifyFilterRule(mfrl)                 add filter rule
   header "name" is|not_is|contains|not_contains|matches|not_matches "value"
   header "name" exists|not_exists
   date before|not_before|after|not_after "YYYYMMDD"
   size under|not_under|over|not_over "1|1K|1M"
   body contains|not_contains "text"
   addressbook in|not_in "header-name"
   attachment exists|not_exists
   fileinto "/path"
   tag "/tag"
   mark read|flagged
   redirect "address"

Also, for add filter rule: mbox> afrl usage:

 addFilterRule(afrl)          [opts] {name}  [*active|inactive] [any|*all] {conditions}+ {actions}+
   -a/--after <arg>             add after filter-name
   -f/--first                   add as first filter rule
   -l/--last                    add as last filter rule
   -b/--before <arg>            add before filter-name

Each zmmailbox script invokes a Java VM (just like zmprov). So you'll want to create a script to be loaded into zmmailbox. That script would look something like
adminAuthenticate ...
selectMailbox user1 ...
addFilterRule rule1 header "from" contains "kevin" discard
addFilterRule rule2 ....
selectMailbox user2
addFilterRule ....

Then you can run it via zmmailbox < scriptname.

Processing a Sieve script and inserting it via zmprov

Alternately you can process the existing Sieve scripts to conform to ZCS expectations and then insert the whole script via zmprov ma account zimbraMailSieveScript ..... You'll need to restrict the entered rules to the Sieve commands as documented above (if ZWC or ZCO are expected to edit them). Each filter rule will need a comment above it; this comment is the filter's name as identified in addFilterRule. Creating one or two simple rules using the web client will give you a framework for the created rule.

Jump to: navigation, search