Thunderbird Run Now Filters Fail on Custom Headers in IMAP Messages

After updating from Mozilla Thunderbird 1.5 to 2.0, I noticed that a manual filter that I had set up stopped working when I clicked the Run Now button. Today, I found a painless and effective workaround for it.

This problem occurs under the following conditions:

  1. The folder is on an IMAP server
  2. The mail filter contains one or more rules that match a custom header
  3. The filter is run manually by selecting “Run Filters on Folder” from the Tools menu or by going to the Message Filters dialog, selecting a folder from the “Run selected filters on” drop down list and then clicking the Run Now button

Note: Filtering on a custom header will work on incoming IMAP mail, just not when run manually on IMAP folders.

The reason the filter fails is that the filter functionality in Thunderbird 2.0 was changed to search the local cache instead of the server and the cache doesn’t contain custom header information, only the standard headers. This change was made because some IMAP servers either don’t have search capability or their implementation is broken.

So, in order to get the filter to work again, Thunderbird needs to have a local copy of all the message headers. Bug 184490, After-the-fact Filters on custom header (eg “User-Agent” or “Newsgroup”) won’t match for IMAP messages, documents this problem and David Bienvenu, in comment #50, gave a very nice workaround for it.

The workaround simply downloads all the messages with all the headers to the local repository for offline use. Hence, Thunderbird can now see all the custom headers and filter on them. To employ the workaround, simply do the following:

  1. Right-click on the folder you want to filter
  2. Select Properties
  3. Click on the Offline tab
  4. Select the “Select this folder for offline use” checkbox
  5. Click the Download Now button to make sure your local copy is up to date
  6. Click the OK button

Now, when you manually run your filter(s), they work! What a relief it was to find this.

20 thoughts on “Thunderbird Run Now Filters Fail on Custom Headers in IMAP Messages”

  1. Oh my, thank you so much for posting this! I was going insane trying to figure out why it wasn’t working. ^.^

  2. Thanks for the feedback, Andrea. I know just how you feel. I was going crazy too when my filters stopped functioning. Glad it worked for you as well.

  3. Thank you for your post, I couldn’t figure out why my X-Mailer filter wasn’t properly working 😉

  4. You’re welcome, jard. Now if I could just figure out why filters fail intermittently when there are lots of new messages (e.g. a couple hundred) in my IMAP Inbox (i.e. when I log into the mail server).

  5. Thanks for this information.
    It whould be great if developers find an other way to download only headers.

    I wrote the info on thunderbird’s page of french Ubuntu’s documentation (

  6. Thank you so much for this. I was having the same problem with with custom views that I wanted to run against a folder. Doing this fixed it great 🙂

  7. I too am very pleased to find out why this isn’t working.

    But, forgive me if I don’t think the workaround is very good.

    If I wanted to download every single mail body, I wouldn’t be using IMAP, would I?

  8. @Anonymous: No need to apologize. Not all workarounds are ideal. Actually, the only ideal workaround is not needing a workaround. 😉

  9. Just what I needed. I thought I was loosing my mind. I had no idea why my List-Id filtered messages wouldn’t work when I had to recreate my profile. Now I do and the fix works. Thanks!

  10. Thanks for the blog post. Save me another 10 frustrating minutes of trying to get me messages filtered.

  11. Thanks a bunch, this really had me extremely perplexed. Custom headers are very important for my spam filtering!

  12. The whole point of IMAP folders is to take advantage of remote mail storage. If I have to download the messages “for offline use”, I might as well use POP. My IMAP folders have 2 to 12 THOUSAND messages in them. This is hundreds of megabytes. While I can and DO appreciate a work-around, I am angry that this kind of gross negligence made it through QA and still is not fixed in the latest Thunderbird.

  13. I’ve been trying to use this workaround without success for a while.

    Turns out, my Thunderbird (Icedove) Offline Settings had “synchronise the most recent 2 weeks” and “Don’t download messages larger than 50kB” set. I don’t remember setting them, but I can’t rule it out…

    So just something to watch out for if you’re not getting the results you expect from manual filtering with the given workaround.