Официальная возможность получить лицензионный софт бесплатно.
Giveaway of the Day
Это не реклама!

Щелкните для получения прогноза по Биробиджану


воскресенье, 27 марта 2016 г.

ZIMBRA: фильтры сообщений, уточнение

В сентябре 2015 я писал про работу с фильтрами сообщений в web-клиенте Zimbra через инструменты zmprov и zmmailbox.
В комментариях к тому посту меня спросили, не пробовал ли я переносить правила фильтров из Thunderbird в Zimbra. Нет, не пробовал - не было необходимости. Но сам вопрос заставил немного порыться в интернетах и нашел я вот такую статью с описаниями относящихся к делу команд zmmailbox, а также условий и действий для фильтров. Возможно, она облегчит подобные преобразования. Поскольку статья помечена как устаревшая, то она может быть удалена и я скопировал ее содержимое сюда


Sieve

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

$ zmmailbox help filter

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

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

  deleteFilterRule(dfrl)       {name}

  deleteOutgoingFilterRule(dofrl) {name}

  getFilterRules(gfrl)         

  getOutgoingFilterRules(gofrl) 

  modifyFilterRule(mfrl)       {name} [*active|inactive] [any|*all] {conditions}+ {actions}+

  modifyOutgoingFilterRule(mofrl) {name} [*active|inactive] [any|*all] {conditions}+ {actions}+

  {conditions}:
    address "comma-separated-header-names" all|localpart|domain is|not_is|contains|not_contains|matches|not_matches [case_sensitive] "value"
    addressbook in|not_in "header-name"
    attachment exists|not_exists
    body contains|not_contains [case_sensitive] "text"
    bulk [not]
    conversation where|not_where started|participated
    current_day_of_week is|not_is "comma-separated-days(0=Sun,6=Sat)"
    current_time before|not_before|after|not_after "HHmm"
    date before|not_before|after|not_after "YYYYMMDD"
    facebook [not]
    flagged [not] "flag"
    header "comma-separated-names" is|not_is|contains|not_contains|matches|not_matches [case_sensitive] "value"
    header "comma-separated-names" exists|not_exists
    importance is|not_is high|normal|low
    invite exists|not_exists
    linkedin [not]
    list [not]
    me in|not_in "header-name"
    mime_header "name" is|not_is|contains|not_contains|matches|not_matches [case_sensitive] "value"
    ranking in|not_in "header-name"
    size under|not_under|over|not_over "1|1K|1M"
    socialcast [not]
    twitter [not]

  {actions}:
    keep
    discard
    fileinto "/path"
    tag "tag"
    flag "flag"
    mark read|flagged|priority
    redirect "address"
    reply "body-template"
    notify "address" "subject-template" "body-template" ["max-body-size(bytes)"]
    stop

Also, for add filter rule: mbox> afrl usage:
 addFilterRule(afrl)          [opts] {name}  [*active|inactive] [any|*all] {conditions}+ {actions}+
   -a/--after              add after filter-name
   -f/--first                   add as first filter rule
   -l/--last                    add as last filter rule
   -b/--before             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. 

Комментариев нет:

Отправить комментарий

Пожалуйста, воздержитесь от грубостей и персональных нападок.
Я не против матерщины, но она должна быть уместной и использоваться для выражения эмоций, а не в качестве основного средства выражения мыслей.