Ipurge

No, it’s not another Apple app, it’s an handy tool that comes with the Cyrus mailserver package to delete mail from IMAP mailboxes. I have setup two entries to get rid of unnecessary messages from the spam and trash folders for all users.
The following rules have been added to the EVENTS list on /etc/cyrus.conf.

<br></br>
# purge trash messages older than 2 weeks<br></br>
purgetrash      cmd="/usr/sbin/ipurge -X -d 14 -f user.*.Trash" at=0600<br></br>
# purge spam messages older than 4 weeks<br></br>
purgetrash      cmd="/usr/sbin/ipurge -X -d 28 -f user.*.Spam" at=0630<br></br>
[/code]<p>It took me some time to figure out the correct matching pattern and at first I was a little bit scared to use the -f option. The man page for ipurge says "-f        Force deletion of mail in all mailboxes." But you'll need it, without it won't work.</p><p>I like this way of cleaning up!</p>```