rock’n roll

December 23, 2005

IMAP filters

Filed under: mail — dinhviethoa @ 6:48 pm

1. History
Most of mailers had IMAP filters rather lately or do not have it. Mac OS X Mail.app, Evolution and Thunderbird have them. Kmail had it lately. Outlook or Sylpheed still do not have mail filtering for IMAP. It looks like this is a difficult problem.

2. Sylpheed-Claws
Let’s take the example of sylpheed. Mail filters for Sylpheed-Claws are applied when retrieving POP mails, which works for POP accounts. This does not apply to IMAP model. In IMAP model, all messages are already the folder.
I implemented something that would give a first solution to this : processing. This is a mail filter that applied to a given mail folder.
Historically, this was introduced to get the same functionnality as Gnus. I was told that it was possible to delete automatically messages that were x days old.
The problem of this solution is that it introduces a performance problem. Everyone don’t want to apply filters on their folders.
We were obviously spending too much time filtering the messages.
To solve that, filters were not applied until some condition was raised : starting browsing the folder and at startup. We also added an option to disable it at startup.

3. Why not to use “processing” ?
Eventually, the use of processing was not that interesting. Most users did not understand the concept of “processing”, we had to define rules to apply before the folder specific rules, define rules to apply after the folder specific rules (when you have rules common to much folders) and there were the rules specific to the folder. Since filtering existed, the user did not understand the goal of “processing”. People did not use it. Then, we’d better not showing it.

4. Ideas for IMAP filtering
In fact, we don’t have to apply filters on all folders since messages that were already filtered will be in folders different that INBOX. We don’t need to filter them again. Then, we only need to apply filters on messages of INBOX.
One additional solution could be to mark messages when they are filtered, so that we evaluate the rules only once on the messages.
Now, we have to choose when to apply the filers. In etPanX, mailboxes will be regularly scanned (STATed) for new messages to update the counter of new messages per mailboxes. Then, before scanning the folders, we could first apply the filters rules on messages.

Update: I was told that sylpheed claws will now filter IMAP mails using filtering rules.

3 Comments »

  1. Mail filters for Sylpheed-Claws are applied when retrieving POP mails, which works for POP accounts. This does not apply to IMAP model. In IMAP model, all messages are already the folder.

    Errr, actually filtering in Claws is applied to IMAP, and local mboxes too. Likewise, the Clam AntiVirus and SpamAssassin plugins filter IMAP mails too.

    Comment by Paul — December 23, 2005 @ 11:15 pm

  2. In fact, I suppose this was left mostly like I designed it. After some verification,
    I could not find any references of “filtering_rules” outside of POP or mbox retrieval.
    Maybe you could point me to the code that applies filtering rules to the IMAP mailboxes.

    Comment by hoa — December 26, 2005 @ 12:12 am

  3. Forgot to answer that. Messages are filtered on IMAP on the following conditions:

    - message is new
    - message is in INBOX
    - INBOX is in a folder with an account
    - “filter on receive” is true

    This is done in folder.c::folder_item_scan_full().

    Comment by Colin — July 3, 2006 @ 10:23 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.