Herostratus’ legacy

words from a lazy coder

the true imap usage: imapfilter

As I said before, I have been using mutt as my e-mail client, and I’m really getting into it. It does what it is supposed to do, cleanly and fast.Nevertheless its support to IMAP lacks of several nice features. One I miss the most is to notice the unread messages in all of my IMAP folders. Yes, what it does is to notices the new e-mails, but if you ignore the announcement, Mutt will not remind you those not-yet-read messages later on.

And that was my biggest fear: Have I missed an important email?

Then I found imapfilter, the IMAP Swiss Army Knife. Using the LUA programming language, you would manipulate your IMAP resources as you want: you can do complex searches, apply operations on messages (move, copy, delete), put flags on them, etc.

So, my task was obtain the list of unread messages in my IMAP account. After a few of LUA exploration, I managed to get this script:

server = IMAP {
server = 'mail.server.com',
username = 'vjaquez',
password = 'myubberpassword',
ssl = 'tls1',

mailboxes, folders = server:list\_all ('\*')
for i,m in pairs (mailboxes) do
-- server\[m\]:check\_status ()
messages = server\[m\]:is\_unseen () -- + server\[m\]:is\_new ()
subjects = server\[m\]:fetch\_fields ({ 'subject' }, messages)
if subjects ~= nil then
print (m)
for j,s in pairs (subjects) do
print (string.format ("t%s", string.sub (s, 0, s:len () - 1)))

It prints out nicely all the messages I haven’t read, so I can go to those IMAP folders, and read them.

Sadly, there’s no way to integrate (as far as I can see) the imapfilter results with Mutt. But that would be amazing! Imagine an IMAP email client manipulated by commands like these.

And those feelings made me recall the Philip’s ideas about integrating Tinymail with Tracker.

And I wonder, does imapfilter support pipelining?