User Tools

Site Tools


internet:mail:zimbra:zimbra_cli

Zimbra Command Line Tools

Delete All Mail in a Folder

First, you might want to move all folders you want to delete, then run the following command on “/Trash”.

zmmailbox -z -m admin@domain.com emptyFolder /foldernamelikeInbox

Delete All Mail in an Account

:!: The above command may be less dangerous to use, but may be a little more work.

:!: Lightly tested - Throws a couple of errors, but seems to work OK.

export ACCOUNT="username@mydomain.com"
for FOLDER in `zmmailbox -z -m $ACCOUNT gaf |awk '/\// {print $5}'|sort|uniq` ; do zmmailbox -z -m $ACCOUNT emptyFolder $FOLDER ; done
unset ACCOUNT

List All Users

https://dilliganesh.wordpress.com/2014/03/23/list-out-all-account-in-zimbra/

su - zimbra
zmprov -l gaa | grep -v -e galsync -e spam -e ham -e virus | sort > /tmp/zimbra_users.txt

For a domain:

zmprov -l gaa yourdomain.tld | grep -v -e galsync -e spam -e ham -e virus | sort > /tmp/yourdomain_users.txt

Get All Addresses

get-all-addresses.sh

#!/bin/bash
set -o nounset   # exit on unset variables
set -o errexit   # exit if command exits with non-zero value
if [ "$(whoami)" != "zimbra" ]; then
  echo "This script must be run as the zimbra user."
  exit 1
fi
RESULTS=( $(zmprov -l gaa -v | grep -E "zimbraMailAlias|zimbraMailDeliveryAddress" ) )
EMAILS=( ${RESULTS[@]/zimbraMail*/} )
for EMAIL in "${EMAILS[@]}"; do
  echo "$EMAIL"
done
zmprov gadl

Manage CoS

:!: defaultExternal can't be used for regular accounts.

Show all CoS:

zmprov gac

Enable a zimlet for all CoS:

for cos in `zmprov gac`;do zmzimletctl acl <zimlet_name> $cos grant; done

Modify a setting for all CoS:

for cos in `zmprov gac`; do zmprov mc $cos zimbraFeatureResetPasswordStatus enabled; done

Show accounts per Class of Service:

zmprov cta domain.tld

Change the CoS for an account:

zmprov sac user@domain.tld another-cos
internet/mail/zimbra/zimbra_cli.txt · Last modified: 2023/03/02 13:36 by gcooper