One challenge in my daily work with my email is dealing with automated mails from Hudson or Bugzilla. As I am involved with several customer projects, I cannot keep track of all the Eclipse committer-related mail during the day.
As I am using GMail, I have become used to the mail filtering mechanism GMail offers to make email sent from Bugzilla or Hudson bypass the inbox and land in a separate IMAP folder (GMail uses a label metaphor, but when accessing mails via IMAP, GMail labels are mapped to IMAP folders).
Until recently, however, there was one problem, which I had not solved for months. As perhaps a lot of people do, I am not only receiving Bugzilla notifications related to bugs for which I am reporter, assignee, or on the CC list, but I also watch other Bugzilla accounts; most notably I, follow the
Of course, this is not a fault of Bugzilla, as Bugzilla sets really useful headers for its emails. In particular, the mails which I denoted as "more important" above can be identified by checking the content of the X-Bugzilla-Reason header. If this header contains CC, Reporter, or AssignedTo, I regard the notification as important. The actual problem is that GMail does not support filtering emails by arbitrary headers (or at least they have hidden that feature so well that I did not find it ...)
To solve the problem for me, I have not installed a small Unix utility called IMAPFilter on my virtual server which I am also using to host this blog. IMAPFilter can be configured via a config file written in the Lua programming language. This way, one can write arbitrary (and sophisticated, if needed) rules and commands to process email stored on one or more IMAP servers. In my case, a quite simple config file does the trick (Note: I still use GMail filtering rules to sort Bugzilla emails into the CDO/Bugzilla folder, because this was configured already, and it makes the IMAPFilter configuration a bit easier):
config.lua | |
myaccount = IMAP { server = 'imap.googlemail.com', username = |
(Note: the plus signs have to be read as logical OR)
That's almost it. The config.lua file goes into ~/.imapfilter and to execute the utility on a regular basis, I have created a crontab entry which calls imapfilter all 15 minutes:
0,15,30,45 * * * * /usr/bin/imapfilter
Naturally, the above is only a simple example. Experiment for yourself to unleash the power of complex mail sorting.