Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Any way to add message filters from command line?

  1. #11
    Daimyo is offline Member
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    Some additional information:

    Curious about the lack of newlines where there ought to be some, I manually tweaked the zmprov.script file (the thing I'm piping to zmprov). It now looks like this:

    Code:
    ma dflynn zimbraMailSieveScript '\
    require ["fileinto", "reject", "tag", "flag"];\
    \n# Helpdesk Tickets\
    \nif anyof (header :contains "subject" "[Lib Help #" )\
    \n{\
    \n    tag "Tickets";\
    \n    flag "flagged";\
    \n    stop;\
    \n}\
    '
    When I pipe this file into zmprov, and then run 'zmprov ga dflynn', I get the following for the zimbraMailSieveScript attribute:

    Code:
    zimbraMailSieveScript: require ["fileinto", "reject", "tag", "flag"];
    # Helpdesk Tickets
    if anyof (header :contains "subject" "[Lib Help #" )
    {
        tag "Tickets";
        flag "flagged";
        stop;
    }
    This looks close to how it should be (judging by the same attribute format on my production Zimbra server, which was created using the filters GUI in the web interface). Unfortunately, I still don't see any filters in the web interface for this account, and I still can't create new ones (I get the error mentioned in my previous post).

  2. #12
    dlbewley is offline Senior Member
    Join Date
    Sep 2006
    Location
    Davis, CA
    Posts
    64
    Rep Power
    8

    Default

    Looks like this is broken in 4.5.6. I just tested and had the same results. One line in the attribute tag and no filters listed in the UI. You might search for or open a bug for this.

    Code:
    [zimbra@zebra tmp]$  cat filters.zmp
    ma jdemo zimbraMailSieveScript '\
    require ["fileinto", "reject", "tag", "flag"];\
    # Helpdesk Tickets\
    if anyof (header :contains "subject" "[Lib Help #" )\
    {\
        tag "Tickets";\
        flag "flagged";\
        stop;\
    }\
    '
    [zimbra@zebra tmp]$ zmprov < filters.zmp
    [zimbra@zebra tmp]$ zmprov ga jdemo |grep Sieve
    zimbraMailSieveScript: require ["fileinto", "reject", "tag", "flag"];# Helpdesk Ticketsif anyof (header :contains "subject" "[Lib Help #" ){    tag "Tickets";    flag "flagged";    stop;}

  3. #13
    Daimyo is offline Member
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    Interesting. I'll look into the bug reports and if I don't see something relevant, I'll call up support and ask them about it.

    Thanks for looking into this - I appreciate your help.

    ~Dave

  4. #14
    bobby is offline Zimbra Employee
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    10

    Default

    The right way to do this is probably through zmmailbox:
    Code:
    zmmailbox -z -m f@test.test addFilterRule "tag special" active any header "subject" contains "special" tag "special" stop
    If you still want to work through zmprov, note that you need a blank line before and after all the filter definitions. To start with, this works for me:

    Code:
    zmprov modifyAccount f@test.test zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];
    
    # tag special
    if anyof (header :contains "subject" "special" )
    {
        tag "special";
            stop;
    }
    '
    That's not especially automated, though, but this perl script does the same thing. The important thing is the single quotes around the $s in the zmprov command.

    Code:
    #!/usr/bin/perl
    
    $s='require ["fileinto", "reject", "tag", "flag"];
    
    # tag special
    if anyof (header :contains "subject" "special" )
    {
        tag "special";
        stop;
    }
    ';
    
    $c="zmprov modifyAccount f\@test.test zimbraMailSieveScript '$s'";
    system($c);
    This is all on Release 4.5.6_GA_1024.RHEL4_20070627170556 RHEL4 NETWORK edition, and the filter matches and tags messages appropriately.
    Last edited by bobby; 07-12-2007 at 02:46 PM.

  5. #15
    Rich Graves is offline Outstanding Member
    Join Date
    Jan 2007
    Location
    Minnesota
    Posts
    718
    Rep Power
    9

    Default Zimbra filters case sensitivity and extensions

    Are Zimbra filter rules case-sensitive?

    What happens if we attempt to define sieve rules with

    :comparator "i;ascii-casemap" or :comparator "i;octet"?

    Are there any other sieve extensions common to Cyrus (specifically Cyrus sieve rules created with Horde's Ingo interface) that we need to look out for?

  6. #16
    bobby is offline Zimbra Employee
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    10

    Default

    The filters UI doesn't really support this (yet), but you can specify the comparator when submitting the raw sieve filter via zmprov. After adding this filter, messages with uppercase "STUFF" in the subject get the "STUFF" tag, but messages with lowercase "stuff" don't:

    Code:
    [zimbra@support5 ~]$ zmprov modifyAccount f@test.test zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];
    
    # tag STUFF
    if anyof (header :contains :comparator "i;octet" "subject" "STUFF" )
    {
        tag "STUFF";
            stop;
    }
    '

  7. #17
    Daimyo is offline Member
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    This is still not working in the way we expect. When I execute the following script:

    Code:
    #!/usr/bin/perl
    
    $s='require ["fileinto", "reject", "tag", "flag"];
    
    # tag special
    if anyof (header :contains "subject" "special" )
    {
        tag "special";
        stop;
    }
    ';
    
    $c="zmprov modifyAccount dflynn zimbraMailSieveScript '$s'";
    system($c);
    I can then examine my account:

    Code:
    zmprov ga dflynn
    Which shows for the zimbraMailSieveScript attribute:

    Code:
    zimbraMailSieveScript: require ["fileinto", "reject", "tag", "flag"];
    
    # tag special
    if anyof (header :contains "subject" "special" )
    {
            tag "special";
            stop;
    }
    All of this looks correct. When I log into the web client, however, and go to my filters, I do not see the one I set through zmprov. If I then set up a filter through the GUI, the zimbraMailSieveScript attribute is overwritten; for example, below is what I see after adding a very simple filter through the web interface immediately after I ran the perl script above.

    Code:
    zimbraMailSieveScript: require ["fileinto", "reject", "tag", "flag"];
    
    # test
    if anyof (header :is "subject" "test" )
    {
        discard;
        stop;
    }
    It isn't immediately clear if the first filter is still working or not, but it is definitely not visible in the web interface. Am I still doing something wrong? Am I wrong to think that a filter I configure through zmprov in this way should be visible (and configurable!) through the web interface?

    Thanks,

    ~Dave

  8. #18
    bobby is offline Zimbra Employee
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    10

    Default

    :/ yeah, I've been restarting tomcat and reloading the web client to make the change show up

  9. #19
    Daimyo is offline Member
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    Ok, I'll give that a shot.

    For the record, while it might be a little annoying to have to restart Tomcat to make this show up to the web interface, what we're doing here is scripting for a large number of users the migration of their Cyrus/Horde filter rules into Zimbra. Once we have the process working and tested, we'll probably do it all at once, in which case restarting Tomcat once to propagate the changes to the web interface is a reasonable thing to do.

    As long as we can use zmprov to migrate the filters and make them visible through the web interface somehow, that's good enough for me. This might be a nice thing to 'fix' in a future release, but as we've noted elsewhere in this thread zmprov isn't really the right tool to begin with. I'd rather use zmprov and restart Tomcat than parse several thousand filter rules and rewrite them into something that zmmailbox understands.

  10. #20
    Daimyo is offline Member
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    The filters UI doesn't really support this (yet), but you can specify the comparator when submitting the raw sieve filter via zmprov. After adding this filter, messages with uppercase "STUFF" in the subject get the "STUFF" tag, but messages with lowercase "stuff" don't
    Does this mean that if I import a filter using zmprov that contains a (for example) :comparator directive, the filter will work but won't show up in the ZWC GUI?

    I ask because I've been able to get some filters to work properly (properly meaning I import them using zmprov ma account@domain zimbraMailSieveScript ..., and I can both test that they work and edit them from the ZWC), and some that do not work. In some cases, the zmprov import seems to work, but the filter doesn't appear to be active, and more importantly it breaks the filter portion of the web client for the affected account - not only can I not see the newly added filter(s), I get an error if I try to create a new one.

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Add Sound to Filters
    By switchisp in forum Users
    Replies: 4
    Last Post: 09-12-2013, 01:07 PM
  2. need advice on configuring zimbra to work with fax server
    By pheonix1t in forum Administrators
    Replies: 0
    Last Post: 07-11-2007, 07:46 PM
  3. Message filters - bulk tagging / filing
    By murky in forum Users
    Replies: 1
    Last Post: 02-09-2007, 12:57 AM
  4. Replies: 42
    Last Post: 08-11-2006, 09:50 AM
  5. Replies: 4
    Last Post: 08-10-2006, 10:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •