Dr. Stefan Winkler
freier Softwareentwickler und IT-Berater

NOTE! This site uses cookies to track your user session.

If you not change browser settings to prevent accepting cookies, you agree to it.

I understand

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 This email address is being protected from spambots. You need JavaScript enabled to view it. Bugzilla notifications to keep myself up to date (at least theoretically ...) with all the current bugs of CDO. The problem was that I wanted to separate the more important notifications (those for which I am reporter, assignee or explicitly part of the CC list) from the less important ones (namely those to emf.cdo-inbox). Most of the time (and here comes practice ...), I have too little time to dig through all the Bugzilla notifications and identify the important ones which I should really care about (or at least read) right now.

 

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 = This email address is being protected from spambots. You need JavaScript enabled to view it.',
   password = 'S3cr3t!!!',
   ssl = 'ssl3'
}

results = myaccount['CDO/Bugzilla']:contain_field('X-Bugzilla-Reason','Reporter') 
  + myaccount['CDO/Bugzilla']:contain_field('X-Bugzilla-Reason','CC') 
  + myaccount['CDO/Bugzilla']:contain_field('X-Bugzilla-Reason','AssignedTo') 

results:move_messages(myaccount['CDO/Bugzilla-Important'])

(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.

Comments   

0 # jcollado 2014-01-26 00:03
I’ve been lately thinking about building a Gmail application that looks at the message headers and takes care of the filtering as you desktop e-mail client would do:
http://www.filtermygmail.com/

Any feedback about this idea would be more than welcome.
Reply | Reply with quote | Quote

Add comment


Security code
Refresh