inbox very large

Dan White dwhite at
Sun Feb 21 01:43:31 EST 2010

On 20/02/10 16:53 -0800, Maria McKinley wrote:
>I have a mailbox that I send spam to, and I have been meaning to set up 
>some filters, so that after a certain period of time, they get deleted. 
>However, I got distracted, and now the inbox is very large. I was 
>wondering if anyone has advice how to 1) get rid of all of the messages 
>currently in the inbox that were sent before a certain date, and 2) how 
>to set up a filter so that messages are moved to folders according to 
>date, and then folders are deleted after a certain date.

Please make sure you have a good backup of your mailstore before performing
any of the below.

For 1), use ipurge. I have the following in my cyrus.conf on one of my
servers (in the EVENTS section):

purgetrash cmd="/usr/sbin/ipurge -f -d 14 */Trash" at=0301

Which purges all messages older than 14 days, in all users' Trash folders
and runs every morning at 3:01am. See the man pages for ipurge and
cyrus.conf for more details.

Sieve filters only act in incoming messages at time of delivery, and to my
knowledge can't be used to do 2).

You could do what you're wanting in a roundabout way by renaming the
mailbox in a periodic basis, recreating the original box, and deleting the
rotated out box.

For instance, you could run a script like this from crontab, once a month:

cat $HOME/last-rotated.txt | grep -q `date +%m%y`
if [ $? -eq 0 ]; then
MONTH=`date +%m`
echo "a01 delete user/jsmith/archive-$MONTH
a02 rename user/jsmith/archive user/jsmith/archive-$MONTH
a03 create user/jsmith/archive
a04 logout" | imtest -m plain -a cyrus -w <secret> localhost
date +%m%y > $HOME/last-rotated.txt

Dan White

More information about the Info-cyrus mailing list