IMAPFilter is a mail filtering utility. It connects to remote mail servers using the Internet Message Access Protocol (IMAP), sends searching queries to the server and processes mailboxes based on the results. It can be used to delete, copy, move, flag, etc. messages residing in mailboxes at the same or different mail servers. The 4rev1 and 4 versions of the IMAP protocol are supported.I'm now using this to get me email back under control. I've created a configuration file for IMAPFilter that will remove all mail from my mailing list mail folders which is older than 30 days. It also marks all mail in the Junk folder as seen. I suppect I'm going to be able to add other stuff too.
The utility is great because it can perform operations on the whole mail box. Mail filters only really work on the incomming message.