I'm running into some issues when trying to create a mail filter for all my users. I've attached the script below I've created for this. Basically, what I've done is thrown the user list into a file with,
Code:
zmaccts | grep "@" | awk '{print $1}' > masteruserlist.log
Then I will be using the following command to create a filter for all my users where any email with [VIRUS] in the subject line will automatically go to their junk folder.

Code:
zmprov modifyAccount useracct@mydomain.com zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];

# Junk Virus Emails
if anyof (header :contains ["subject"] "[VIRUS]") {
    fileinto "Junk";
    stop;
}
'

Here is the entire script,

Code:
#!/bin/bash

##################################################################################
#                                                                                #
# Command to create a filter to move any email to Junk with [VIRUS] in subject   #
#                                                                                #
##################################################################################


addfilter () {

zmprov modifyAccount $user zimbraMailSieveScript 'require ["fileinto", "reject", "tag", "flag"];

# Junk Virus Emails
if anyof (header :contains ["subject"] "[VIRUS]") {
    fileinto "Junk";
    stop;
}
'
}

################################################
#                                              #
# Creating Loop to add users to above command  #
#                                              #
################################################

exec 0</dev/shm/userlist.log
while read user
do

 echo "Attempting to read masteruserlist.log"
  [ -z "$user" ]
   set $user
    user=$1
     addfilter

     done

Now, here are my main issues -

1. Unable to run the script as the zimbra user.

2. When I successfully run the script, all other filters the user has are erased. This cannot happen.

Does anyone have any suggestions for this? We recently switched to Untangle as our spam filter and no longer use Zimbra's.