Warning: I publish this addon as is. It is a Proof Of Concept. It
works well enough for my needs, and I don't have the time
neither the Javascript and Thunderbird internals expertise to
create a real addon usable by regular users.
Sorry for that. I already invested too much time on this. I am a
consultant, btw, so you could just pay me :-).
This code is BSD licensed.
Background
When you get a lot of email you need filtering. Filtering allows
you to classify incoming email in folders, tag it, flag it, delete
it, etc. automatically.
Thunderbird can do client-side filtering easily. And you can do
it both for POP3 and IMAP4 servers. But one of the real
advantages of IMAP4 is that you can access the same folders,
concurrently, from different devices. If you access your email
from your smartphone but your filtering is done by Thunderbird
running on your laptop, you will have a mess in your inbox when
you are in the road and Thunderbird is not running.
Moving the filters to the server is very convenient: the filters
are execute for every incoming email, even if all your devices are
offline. Your mailboxes are tidy and ready to be accessed
anytime by any device.
The standard for server-side filtering is called Sieve.
There is an issue, though. With Sieve you can get new email in
any of your email folders (mailboxes, in IMAP4 speak), not only
in inbox. Standard IMAP4 only notify changes in folders you
have selected, and you can only select a folder per connection.
Even if you email client opens ten simultaneous connections to the
IMAP4 server you can only monitor ten folders. If you have twenty
folders and all of them can get new email, you will miss updates.
You can see this clearly in Thunderbird. You see that a
particular folder has seven unread emails. You select that folder
in the GUI and now the counters are updated and you actually have
nine unread messages. You don't get the update until you select
that folder.