Results 1 to 9 of 9

Thread: Contrib: How to delete emails based on subject script

Threaded View

  1. #1
    Join Date
    Oct 2006
    Rep Power

    Default Contrib: How to delete emails based on subject script

    This may be an old thread, but I ran into this same problem today so I thought I'd share the script I used in case someone else stumbles across this thread via a search engine like I did.

    I had a user who sent about 50mb of photographs to every one of the users in her address book. Multiple times if they were in multiple distribution lists. Since I have multiple remote sites that use my Zimbra server via a couple shared DSL lines, this clobbered all the remote locations.

    I took examples from a couple of the sources linked earlier in the thread (bdial's psudocode and King0770's script), and combined them. It runs about 35 accounts per minute on my system, so it wouldn't scale too well for larger installations, but it is still way faster than doing it by hand.

    The expected inputs are the from_username and subject. The script steps through each account on the server and deletes any messages it finds from the user provided and with the subject provided.

    I ran: ./ Smart_User "(no subject)"
    Smart_User isn't a big fan of filling in the subject when she sends emails so there was some collateral damage, but I didn't care at that point.

    # user subject
    if [ -z "$2" ]; then
     echo "usage: <fromuser_name> <subject>"
     echo "  Rummages through all mail boxes looking for messages from <fromuser_name> with subject=<subject>"
     echo "  Example: ./ butthead_user rems "
     echo "  Put double-quotes around multi-word subjects"
     exit 0
     for usractnopac in `zmprov gaa`
       echo "Searching $usractnopac  for Subject:  $subject From: $addr"
       for msg in `zmmailbox -z -m "$usractnopac" s -l 999 -t message "from:$addr subject:$subject"|awk '{ if (NR!=1) {print}}' |
          grep -v -e Id -e "-" -e "^$" | awk '{ print $2 }'`
            echo "Removing "$msg""
            zmmailbox -z -m $usractnopac dm $msg
    Last edited by pacsteel; 01-20-2010 at 04:58 PM. Reason: attribution
    Production: 5.0.18_GA_3011.UBUNTU8 FOSS Ubuntu 8.04 LTS
    Tested: 7.1.4_GA_2555.UBUNTU10_64 NETWORK edition Ubuntu 10.04.4 LTS
    Left Zimbra for a different product in 2011, thinking about coming back.

Similar Threads

  1. Replies: 4
    Last Post: 09-16-2012, 06:33 PM
  2. Replies: 0
    Last Post: 05-07-2009, 10:35 AM
  3. zimbra opesource Backup Script Problem!
    By tashi in forum Administrators
    Replies: 4
    Last Post: 03-30-2009, 11:49 PM
  4. Zimbra Open Source Backup Help
    By ayush1440 in forum Administrators
    Replies: 8
    Last Post: 11-13-2008, 03:56 AM
  5. Delete tagged emails
    By EriSan500 in forum Users
    Replies: 1
    Last Post: 01-31-2006, 06:59 AM

Posting Permissions

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