Don’t call me DOM

3 August 2004

Mailing-list based filtering and IMAP

Filed under:

Given the big number of mails I receive (around 150 a day), and given that most of it comes from W3C mailing lists (around 80%), I sort all my incoming emails based on the mailing list they were sent to, which allows me to see at a quick glance what mails I should read in priority. Procmail allows to do so quite easily with the following rule:

# filter mail from W3C mailing lists
* ^List-Id: <[a-z0-9-]>
* ^List-Id: </[a-z0-9-]+

(List-Id is a header defined in RFC 2919 precisely to make it possible to handle mailing lists messages)

The only problem with that approach is that, using IMAP, I only get to see mails from mailboxes I have explicitly subscribed to; also, I can only subscribe to a mailbox that already contains emails. While there are workarounds for these issues, I eventually wrote the following little assistant that detects which mailboxes have received mails recently and to which I’m not subscribed:

cd /home/dom/mail;  for i in * ; do if [ -z "`grep "$i" ./home/dom/mail/subscriptions`" ] ; then  if [ `stat -c "%Y" "$i"` -gt `stat -c "%Y" /home/dom/mail/.subscriptions` ] ; then echo $i ; fi ; fi ; done

.subscriptions is the file used by our IMAP server to track which mailboxes one is subscribed to; so this scripts compares the list of mailboxes with the list of subscribed mailboxes; for mailboxes to which I’m not subscribed, it checks whether any recent message has been received (using stat -c "%Y").

Calling it from a daily cronjob, I should get a message listing new mailboxes I’m not IMAP-subscribed to when this happens.

Picture of Dominique Hazael-MassieuxDominique Hazaël-Massieux ( is part of the World Wide Web Consortium (W3C) Staff; his interests cover a number of Web technologies, as well as the usage of open source software in a distributed work environment.