Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

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

  1. #21
    Join Date
    Jul 2007
    Posts
    14
    Rep Power
    8

    Default

    One more (general) question:

    Is there documentation somewhere that explains exactly what portion of Sieve the ZWC currently supports? I'm running into lots of errors that are related to particular directives from Cyrus/INGO that do not appear to work in the Zimbra web client. If I knew exactly what was supported and what was not, I could throw out filter rules that wouldn't import properly and still be able to get some stuff migrated.

  2. #22
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    11

    Default

    >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?
    >
    That's the way it looks to me. I didn't get any errors in the web client, but the filters rules UI was definitely displaying the rules wrong. It's possible that using the UI to add or edit rules will corrupt these rules.

    >Is there documentation somewhere
    ZCS uses jsieve, which seems pretty complete. There is a zimbra mail filtering doc but it doesn't cover everything jsieve can do.

  3. #23
    Join Date
    Nov 2006
    Location
    Buffalo, NY
    Posts
    47
    Rep Power
    9

    Default

    I've gotten the examples to work to add a filter however, what would I need to do to add an 'additional' filter (for example, if the user alrady had a filter or folters)? Would I need to find their current filters, build a new 'zimbraMailSieveScript' description, and then apply both the old and the new for each account? Or is there an easier was to use 'zmprov' to batch add a filter in addition to any filters the user might already have?
    Thanks,
    Jim...
    Jim...

  4. #24
    Join Date
    Nov 2005
    Posts
    518
    Rep Power
    11

  5. #25
    Join Date
    Oct 2009
    Posts
    7
    Rep Power
    6

    Default

    I'd like to give my contribution to this discussion.

    We've recently migrated from Postfix+Dovecot to Zimbra and we had the same issue with filter rules.

    We had this kind of input:

    Code:
    #### machinename ##### 
    if address :is "From" "root@machinename.domain.tld" { 
      # CRON 
      if header :contains ["Subject"] ["Cron <root@machinename.domain.tld>"] { 
        fileinto "INBOX.machinename.cron"; 
        stop; 
      } 
      # LOGWATCH 
      if header :contains ["Subject"] ["Logwatch for"] { 
        fileinto "INBOX.machinename.logwatch"; 
        stop; 
      } 
      # CATCHALL 
      fileinto "INBOX.machinename"; 
      stop; 
    } 
    ##################
    So we solved the situation with this perl script:
    Code:
    #!/usr/bin/perl -w
    
    use warnings;
    use strict;
    
    open(FILE,"dovecot.sieve") || die ('unable to read rules');
    my @line=<FILE>;
    close(FILE);
    
    my @rule;
    my $index=0;
    
    foreach my $val (@line) {
            next if $val =~ m/^$/;
            if ($val =~ m/#### (.*) #####/) {
                    $rule[$index]{machine} = $1;  
            }
            if ($val =~ m/if header :contains \["Subject"\] \["Cron <(.*@.*)>"\]/) {
                    $rule[$index]{cron} = $1; 
            }
            if ($val =~ m/##################/) {
                    $index++;
            }
    }
    
    for my $i ( 0 .. $#rule ) { 
    
                    my $machine=$rule[$i]{machine};
                    my $mailcron=$rule[$i]{cron};
    
                    print "zmmailbox -a admin -p accountpass -m accountname afrl $machine.cron header \"Subject\" contains \"Cron <root\@$machine>\" fileinto /Inbox/$machine.cron\n";
                    print "zmmailbox -a admin -p accountpass -m accountname afrl $machine.logwatch header  \"Subject\" contains \"Logwatch for\" fileinto /Inbox/$machine.logwatch\n";
                    print "zmmailbox -a admin -p accountpass -m accountname afrl $machine.catchall header \"From\" contains \"root\@$machine.hermess.it\" fileinto /Inbox/$machine\n";
    }
    A little bit...raw, but it works!

Similar Threads

  1. Add Sound to Filters
    By switchisp in forum Users
    Replies: 4
    Last Post: 09-12-2013, 02: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, 08: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, 10:50 AM
  5. Replies: 4
    Last Post: 08-10-2006, 11: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
  •