King0770-Notes-Removal of Bad Contact Address

Revision as of 23:03, 25 November 2009 by King0770 (talk | contribs)

Here's a small script to remove a bad contact address for all users. Sometimes users will accidentally send a message to a bad address, contaminating their contact folder, "Emailed Contacts". Through circumstance, bad contact addresses can be populated in a user's contact folders, this can be a nuisance for the autocomplete feature if the user is not paying a attention to the address.


if [ -z "$1" ]; then
echo "usage:"
exit 0

if [ `whoami` != "zimbra" ]; then
        echo "You must be the zimbra user to run this script."
                exit 0

for i in `zmprov -l gaa`
BADADDR=`zmmailbox -z -m "$i" s -t contact "$1" | awk '{ if (NR!=1) {print}}' | grep -v -e Id -e "-" | awk '{ print $2 }' | grep -v "^$"`
        if [ "$RETVAL" = 0 ]; then
          echo "Removing "$1" from "$i"" >> /tmp/remove_badaddress.$$
          zmmailbox -z -m "$i" dct "$BADADDR"
Jump to: navigation, search