Tag Archives: zmztozmig

Migrate Zimbra mail filter rules between servers

This is a short HOWTO migrate Zimbra mail filter rules from one server to another or even copy the rules from one user and import them to another. These commands are useful to use when you migrate user accounts between servers since mail filters are not migrated using the Zimbra to Zimbra migration script, zmztozmig . I might write a short post about migrating users between Zimbra servers later.

Export the rules to a file named filter_rules.sieve as the zimbra user

# zmprov ga user@example.com zimbraMailSieveScript > filter_rules.sieve

The content of the file could look something like this

# name user@example.com
zimbraMailSieveScript require ["fileinto", "reject", "tag", "flag"];

# Filtername
if anyof (header :contains ["to"] "root@localhost") {
    fileinto "foldername";
    stop;
}

Copy the filter_rules.sieve file to the other server and import the filter rules by enclosing the filter rules with a single qoutes around the rules

# zmprov ma user@example.com zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];

# Filtername
if anyof (header :contains ["to"] "root@localhost") {
    fileinto "foldername";
    stop;
}'

This has been tested on a Zimbra 7.1.1 OSE server after migrating some users mailboxes from a 32-bit Zimbra server to a new 64-bit server.