I’ve been looking for something to manage my inbox, I already use procmail to file mails into folders as they arrive, but I end up with a lot of emails that need tidying up later. For example, I receive the weekly BBC 4 progamme guide email – after a week the programmes have been shown and the email is useless. Similarly eBay search alerts.
I was going to write my own mail filter in python, but then discovered imapfilter which is in the EPEL repositories for Centos/RHEL. It’s fantastic – you write your rules in lua (which is very straightforward, certainly more so than procmail’s custom language), set it to run in cron and off it goes. An example config file is below:
myaccount = IMAP {
server = 'localhost',
username = 'jp',
password = 'N0tmyrealpw',
ssl = 'tls12'
}
-- get seen messages from inbox older than 10 days
inboxmsgs = myaccount.INBOX:is_seen()
oldmsgs = inboxmsgs:is_older(10)
-- further filter from these senders
delmsgs = oldmsgs:match_from('.*(bbcfournewsletter|humblebundle|googlealerts|Transport_for_London|sourceforge).*')
delmsgs:delete_messages()
-- get old messages from shopping, ebay & cron folders
shopmsgs = myaccount['saved/shopping']:is_older(14) + myaccount['saved/ebaysearch']:is_older(3) +
myaccount['saved/cron']:is_older(14)
shopmsgs:delete_messages()