I have a dozen or so SVN projects that generate a few dozen email messages every day, each with subject line like this [SVN projectname] in branch/trunk list of files.

I want to send these email messages to a folder automatically (for weekly review), but if somebody sends me a comment regarding an SVN commit (which typically has subject line "Re: [SVN projectname] ...") then I don't want to send the message to the folder, since it is likely to require immediate action.

What is the best way to address this Gmail filtering requirement?

Simply specifying a Gmail filter that sends messages with subject [SVN projectname] to a folder is too general, because such a filter will take both the messages that I want to filter and some (like the Replies mentioned above) that I don't want filtered. I would describe the "pattern" I want like this:

/^\[SVN projectname\]/

I am aware that full regular expression filter support is both resource intensive and prone to security holes, which is why I've chosen the example (which is real, by the way) carefully - the "left anchor" pattern is the easiest and most efficient (to implement) type of text matching pattern that I can think of (except maybe a check on minimum/maximum string length).

I am also aware that I can use the "From" filter (and in some cases the "To" filter) to distinguish between messages which are automatically generated by SVN and messages which are generated by humans (and indeed, that is my current "workaround" for the fact that I cannot use a better filtering pattern for the subject line). But IMO this is not a real solution, because it means that I must tweak my mail filtering rules each time we change the hosting location of an SVN repository, for example - and if I write filters based on "To" then I need to tweak them when we change our email aliases.

Indeed, the very existence of "To" and "From" filters in Gmail acknowledges that email headers contain metadata which naturally calls for "fielded search" as opposed to the "(free) text search" which works so well for the message body. But in order to dissect the elements of an email workflow we need pattern matching which is sensitive enough to distinguish between an "original" message and a "reply", and it has been standard email client behavior for many years to encode this in the construction of the subject line. So it seems silly that we cannot take advantage of this fact when writing our Gmail filters.

  • I don't think this is a good question for SO. – Qtax Jul 8 '11 at 13:12
  • Could you please explain why not? – Peter Jul 8 '11 at 13:44
  • (Just sounded to me like a "why doesn't application X have feature Y?" question, where X is not programming/development related anyway. But never mind.) – Qtax Jul 8 '11 at 14:21
  • I tried posting a Gmail feature request here but have heard only deafening silence. I know Gmail users have been fruitlessly clamoring for generic regex support (when filtering SMTP header values) for years, now. But what I'm asking for is much more specific, and much easier to implement. – Peter Sep 6 '11 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.