I'd like to archive mails when the mailbox size exceeds
a set number. Along with this I'd like to sort by
certain criteria before truncating the overflow emails.
For example:
To limit the mailbox to the 2000 newest emails:
archivemail --sortby=date --limit=2000 mailbox
To limit the mailbox to the 2000 oldest emails:
archivemail --sortby=reversedate --limit=2000 mailbox
To limit the mailbox to the 2000 least egregious spams,
as reported by SpamAssassin:
archivemail --sortby=number
--keypattern='^X-Spam-Status:.*hits=([0-9.]*)'
--limit=2000 mailbox
Here --keypattern allows us to specify a regular
expression that captures the sort key. --sortby then
treats this key as a number for sorting purposes.
(--sortby=number and --sortby=alpha require --keypattern)
Perhaps if there is no sort criteria, it defaults to
"date"...
I hope you like this idea. It would allow me to get rid
of my homegrown solution and use a more standard one.