Zimbra Filter rules? (solved)

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Zimbra Filter rules? (solved)

Post by killmasta93 »

Hi i was wondering if someone has accomplished what im trying to do,
Currently i need to create a filter for all the email users and future users.
I could not find a way on the web console to add that filter without doing one by one,
I did see this command

Code: Select all

zmmailbox addFilterRule
but it would be the same way adding one by one so not sure if any more ideas?

Thank you
Last edited by killmasta93 on Wed Jun 23, 2021 2:10 pm, edited 1 time in total.
7224jobe
Outstanding Member
Outstanding Member
Posts: 283
Joined: Sat Sep 13, 2014 1:55 am
ZCS/ZD Version: 8.8.15_FOSS Patch38

Re: Zimbra Filter rules?

Post by 7224jobe »

Hi, yes, to create a filter for all users you have to use command line. Take a look here (2nd message): viewtopic.php?t=69112
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: Zimbra Filter rules?

Post by barrydegraaff »

You can use Sieve filters in case it is about incoming emails:

https://github.com/Zimbra-Community/zim ... r/Sieve.md

If you want to use filtering for outgoing emails, you can probably best use Milter.
--
Barry de Graaff
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: Zimbra Filter rules?

Post by killmasta93 »

barrydegraaff wrote:You can use Sieve filters in case it is about incoming emails:

https://github.com/Zimbra-Community/zim ... r/Sieve.md

If you want to use filtering for outgoing emails, you can probably best use Milter.
Thanks for the reply this sieve would automatically add the option to all users and new users on zimbra?

so i would create script

Code: Select all

/tmp/myfilters/email.sh

inside would be this

Code: Select all

#Filter email based on a subject
if header :contains "Subject" [
  "SPAM"
  ]
{
    fileinto "spamfolder";
    stop;
}
which any email that comes from my spam gateway with subject would go to the spamfolder correct?

but not sure which part to add this filter for all the emails in that domain?
i read the last part but it says per account?

Thank you
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: Zimbra Filter rules?

Post by killmasta93 »

7224jobe wrote:Hi, yes, to create a filter for all users you have to use command line. Take a look here (2nd message): viewtopic.php?t=69112
i was also reading that second topic and the command applies for all users?

Code: Select all

zmprov -l gaa` ; do zmmailbox -z -m $i afrl "BITCOIN" active all body contains "bitcoin" fileinto "Trash" ; done
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: Zimbra Filter rules?

Post by barrydegraaff »

This will add the script in /tmp/myfilters to the example.com domain, and this will work for all the users in the domain, including future ones.
cat /tmp/myfilters |xargs -0 zmprov md example.com zimbraAdminSieveScriptBefore
--
Barry de Graaff
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: Zimbra Filter rules?

Post by killmasta93 »

barrydegraaff wrote:This will add the script in /tmp/myfilters to the example.com domain, and this will work for all the users in the domain, including future ones.
cat /tmp/myfilters |xargs -0 zmprov md example.com zimbraAdminSieveScriptBefore
Thank you again for the reply,
that did the trick,
Out of curiosity how could i disable a filter if i would need to? or disable per user?
as on the webconsole i go to filters but i dont see that filter i did though command line

Thank you
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: Zimbra Filter rules?

Post by barrydegraaff »

This will add the script in /tmp/myfilters to the example.com domain, and this will work for all the users in the domain, including future ones.

cat /tmp/myfilters |xargs -0 zmprov md example.com zimbraAdminSieveScriptBefore

Now let's say we have a VIP user with different rules, we apply /tmp/viprules to vip@example.com

cat /tmp/viprules |xargs -0 zmprov ma vip@example.com zimbraAdminSieveScriptBefore

Setting set directly on the account override the domain ones. Settings on the domain override the global config etc.

There is no GUI for this, so it is all command line based.
--
Barry de Graaff
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: Zimbra Filter rules?

Post by killmasta93 »

thank you so much that did the trick
killmasta93
Posts: 47
Joined: Tue Oct 04, 2016 9:54 pm

Re: Zimbra Filter rules?

Post by killmasta93 »

barrydegraaff wrote:This will add the script in /tmp/myfilters to the example.com domain, and this will work for all the users in the domain, including future ones.

cat /tmp/myfilters |xargs -0 zmprov md example.com zimbraAdminSieveScriptBefore

Now let's say we have a VIP user with different rules, we apply /tmp/viprules to vip@example.com

cat /tmp/viprules |xargs -0 zmprov ma vip@example.com zimbraAdminSieveScriptBefore

Setting set directly on the account override the domain ones. Settings on the domain override the global config etc.

There is no GUI for this, so it is all command line based.

Quick question i tried to test out to disable all by

Code: Select all

zmprov mc default zimbraSieveEditHeaderEnabled FALSE

but the filters keep working
Post Reply