Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Delete un-read email older the X days

  1. #1
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default Delete un-read email older the X days

    I'm looking to delete emails from my users mailboxes that are unread and over X number of days old. Any thoughts on how I might do this? I

  2. #2
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

  3. #3
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default

    Is the query a SQL search into the MySQL DB? Is there a easy way to get a list of the valid fields?

  4. #4
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

    Default

    If you run 'zmmailbox help' it will give you a list of help sections that describe the fields you can use to search.
    Last edited by phoenix; 02-18-2009 at 06:56 AM.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  5. #5
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    12

    Default

    Another (probably better) option is to set zimbraPrefInboxUnreadLifetime on the account.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  6. #6
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default

    zimbraPrefInboxUnreadLifetime would be an awesome/easy way to do this, but I need to script something that will fit within our business rules.

    Is there anymore docs on the search rather then zmmailbox help search?

  7. #7
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default

    zmmailbox help search doesn't really give any details on how to search for messages within a date range. What I'm doing to find the messages I want to delete is:

    1. zmprov getMailboxInfo userid@domain.
    2. Get the mboxgrooup#
    3. Logging into mysql using a query to find the messages.
    4. Then zmmailbox -z -m userid@domain deleteItem #-#

    My question is what format is the date field? I see it is a unsigned int.

  8. #8
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default

    Can anybody decipher date: 1209569274

  9. #9
    Join Date
    Feb 2007
    Location
    Sioux Falls, SD
    Posts
    67
    Rep Power
    8

    Default

    Quote Originally Posted by drhughes View Post
    Can anybody decipher date: 1209569274
    That is a UNIX time stamp.

    1209569274 = Wed, 30 Apr 2008 15:27:54 GMT

    Used Epoch Converter - Unix Timestamp Converter to convert it to human readable format.

    Hope that helps!
    Dusty
    CoSentry - www.cosentry.com - Co-Location & Business Resiliency Solutions

  10. #10
    Join Date
    Dec 2007
    Posts
    50
    Rep Power
    8

    Default Delete messages older then x number of days

    Below is some code I have been playing with in a test environment. It will move unread email that is older then x number of days to the users /Trash folder for the system to clean up later.

    I use three mailbox servers so I have designed the code to run on all three machines.

    I strongly suggest making a backup before running. Use the following code at your own risk. I take no responsibility. You have been warned.

    Code:
    #!/bin/bash
    #Move unread mail older then givendate from users mailboxes to /Trash
    #Make a backup before running.  
    #
    #USE AT YOUR OWN RISK!
    #
    
    emaildomain="enter_email_domain_here"
    
    days=$(date -d $1' days ago' '+%D')
    hn=`hostname`"."`dnsdomainname`
    
    who=`whoami`
    if [ "$who" != "zimbra" ]
    then
     echo
     echo "Please su to the zimbra user before running this script"
     echo
     exit
    fi
    
    if [ -z "$1" ]; then
     echo
            echo -e "\nUsage: deletemail <number of days ago>"
            echo
            exit
    fi
    
    echo "Deleting messages older then $days"
    
    echo "Building user list for $hn"
    zmprov gqu $hn | grep $emaildomain |cut -f 1 -d' '> /tmp/del-$hn.tmp
    
    echo "Moving mail to /Trash"
    for x in $(tail -1 /tmp/del-$hn.tmp)
    do
     echo "Currently working on: $x"
     for y in $(zmmailbox -z -m $x search -t message -l 9999 "(before:$days)(is:unread)"|awk {'print $2'}|grep [0-9]|grep -v ,)
     do
      zmmailbox -z -m $x mm $y "/Trash"
      zmmailbox -z -m $x fm $y 1
     done
    done

Similar Threads

  1. bayes db..
    By osiris in forum Administrators
    Replies: 9
    Last Post: 06-15-2011, 12:14 PM
  2. Not receiving from given domain
    By jrefl5 in forum Administrators
    Replies: 19
    Last Post: 02-29-2008, 11:45 AM
  3. 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
  4. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 03:56 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
  •