About filter rules

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
Desler
Posts: 5
Joined: Sat Sep 13, 2014 3:52 am

About filter rules

Post by Desler »

Hi! I use ZCS 8.0.6 and I have a some question about filter rules.
How can I run the existing filter rule from command line? With zmmailbox I can create, modify or get filter rules, but not to run it.
My task is this: I need script for periodically check all mailboxes for mails with specific subject and from specific address, and delete if messages older than n days.

It seems to me that filter rule is most easy way to perform this job, but unfortunately I could not find anything in the documentation about commands to run the filters task.
User avatar
ccelis5215
Outstanding Member
Outstanding Member
Posts: 632
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.8.15.GA.3869.UBUNTU18.64 P12

About filter rules

Post by ccelis5215 »

hi Desler,
You can do your task using in two ways:
1.- Script using zmmailbox to search and delete messages based in you criteria.

2.- Using filter to move messages to a folder and then applying retention to the folder.
Let us know if you need more details.
ccelis
Desler
Posts: 5
Joined: Sat Sep 13, 2014 3:52 am

About filter rules

Post by Desler »

[quote user="ccelis5215"]hi Desler,
You can do your task using in two ways:
1.- Script using zmmailbox to search and delete messages based in you criteria.

2.- Using filter to move messages to a folder and then applying retention to the folder.
Let us know if you need more details.
ccelis[/QUOTE]
1. Unfortunately it is very slow option. When I try to use deleteConversation and deleteMessage this commands took a one or two seconds per one message.

Maybe I do something wrong but I use this syntax:

zmmailbox -z -m deleteConversation

zmmailbox -z -m deleteMessage

And as far as I know there is no way to simultaneously delete messages using this commands. Or it is wrong?

I have a very big number of letters to use deleteConversation and deleteMessage if they deleting one message per iteration.
2. My problem is that I need to use the filter not from GUI. I want to run filter from the command line. Because I hane many user accounts and want to apply filter to all users.

I can create filter by using:

zmmailbox -z -m afrl

My question - how I can run this filter from command line?
Desler
Posts: 5
Joined: Sat Sep 13, 2014 3:52 am

About filter rules

Post by Desler »

SOLVED! May it be interesting to others. There is way to run filter rule from command line:
zmsoap -z -m -f
File with request is in xml format and using ApplyFilterRules SOAP Command:








in:"inbox" OR in:"Trash"

rojoblandino
Advanced member
Advanced member
Posts: 52
Joined: Sat Sep 13, 2014 1:36 am

Re: About filter rules

Post by rojoblandino »

Desler wrote:SOLVED! May it be interesting to others. There is way to run filter rule from command line:
zmsoap -z -m -f
File with request is in xml format and using ApplyFilterRules SOAP Command:
in:"inbox" OR in:"Trash"
May you please write an xml example I have search in google the xml format for ApplyFilterRules and what i have found is only this:

<ApplyFilterRulesRequest>
<filterRules>
<filterRule name="{name}"/>+
</filterRules>
[<m ids="{msg-id-list}"/>]
[<query>{query-string}</query>]
</ApplyFilterRulesRequest>

I have tried to apply it with not success.
<ApplyFilterRulesRequest>
<filterRules>
<filterRule name="Services"/>
</filterRules>
</ApplyFilterRulesRequest>
ERROR: service.UNKNOWN_DOCUMENT (unknown document: ApplyFilterRulesRequest)

<ApplyFilterRules>
<filterRules>
<filterRule name="Services"/>
</filterRules>
</ApplyFilterRules>
ERROR: service.UNKNOWN_DOCUMENT (unknown document: ApplyFilterRules)

Where should be option in:"INBOX"?
User avatar
DanielEugenin
Posts: 16
Joined: Thu Sep 19, 2013 9:51 am
Location: Chile
ZCS/ZD Version: 9.0.0_GA_3924.RHEL7_64_202003310103
Contact:

Re: About filter rules

Post by DanielEugenin »

Hi rojoblandino,.

I have an example without using xml file, just execute:

Code: Select all

zmsoap  -z -m user@domain.com ApplyFilterRulesRequest/filterRules/filterRule @name="Services" ../../query="in:/Inbox"
Where:
@name="Services" is the name of your filter created.
query => execute filter on /Inbox folder
rojoblandino
Advanced member
Advanced member
Posts: 52
Joined: Sat Sep 13, 2014 1:36 am

Re: About filter rules

Post by rojoblandino »

DanielEugenin wrote:Hi rojoblandino,.

I have an example without using xml file, just execute:

Code: Select all

zmsoap  -z -m user@domain.com ApplyFilterRulesRequest/filterRules/filterRule @name="Services" ../../query="in:/Inbox"
Where:
@name="Services" is the name of your filter created.
query => execute filter on /Inbox folder

It is Perfect!

That is what i was looking for, Thanks!
bioroido
Posts: 1
Joined: Thu Nov 09, 2017 10:35 am

Re: About filter rules

Post by bioroido »

Hello
Found here very useful command, but here is problem
zimbra@mail:/root$ zmsoap -z -m username@mail.server.com ApplyFilterRulesRequest/filterRules/filterRule @name="2012" ../../query="in:/Inbox"
ERROR: service.INVALID_REQUEST (invalid request: Attempted to apply filter rules to 95053 messages, which exceeded the limit of 10000)
Is that any way to change this limit?
8.6.0_GA_1153.FOSS
aaaalbi
Posts: 1
Joined: Thu Sep 03, 2020 6:46 am

Re: About filter rules

Post by aaaalbi »

bioroido wrote:Hello
Found here very useful command, but here is problem
zimbra@mail:/root$ zmsoap -z -m username@mail.server.com ApplyFilterRulesRequest/filterRules/filterRule @name="2012" ../../query="in:/Inbox"
ERROR: service.INVALID_REQUEST (invalid request: Attempted to apply filter rules to 95053 messages, which exceeded the limit of 10000)
Is that any way to change this limit?
8.6.0_GA_1153.FOSS
This will do it, change "default" to your COS:
zmprov mc default zimbraFilterBatchSize 2000000
Max Zamaraev
Posts: 2
Joined: Wed Jan 12, 2022 4:38 pm

Re: About filter rules

Post by Max Zamaraev »

DanielEugenin wrote:Hi rojoblandino,.

I have an example without using xml file, just execute:

Code: Select all

zmsoap  -z -m user@domain.com ApplyFilterRulesRequest/filterRules/filterRule @name="Services" ../../query="in:/Inbox"
Where:
@name="Services" is the name of your filter created.
query => execute filter on /Inbox folder
Daniel, thanks for the brilliant idea!
Don't you know if there is the way to apply ALL active rules that user has? Rules in my case can be added or removed by user without notifications.

TIA
Post Reply