and IMAP Folders

For some time, I've been annoyed by not checking all folders every time it checks mail. My situation is that I have an IMAP server at a colo, a Mac Pro at home usually with running and more importantly, running its filters, and a MacBook running that I take with me to work or wherever.

The problem is that as mail comes in and gets filtered by the Pro, the laptop continues to check mail every minute. However it does not "see" messages that get filtered off. So if Dave sends me mail and it goes to the Dave folder, the only way I notice it is if I manually click that folder, which isn't happening.

So how do you fix it? I know there is probably a way, but I've not found an official answer to this in the months I've been looking, so here's what I've got that actually works.

Hit the Mailbox menu and select New Smart Folder. Use "Message is not in mailbox" rules if you don't want to check things like your spam folder (I have my spam stored on the server so if something gets filtered, I see it. Also make a rule to specify "Message Type" as "Mail" so it excludes any RSS feeds you have.

This should hit every folder you have, and when it does, it will actually "touch" that folder, and make the unread message count for that folder update. So what I've done was just collapse the "Smart Mailboxes" in Mail, and I'll probably forget that thing exists, since the unread message counts are now correct.

Woo, yay Apple. My life clearly isn't complicated enough. I'll update this with screenshots later, this is kind of a draft so I remember what I did.

UPDATE 11-10-2009:
I had some luck using FAM (File Alteration Monitor) on the server side (Courier). Since every mail in a Maildir directory is a separate file, FAM is able to check that filesystem for changes, report that to Courier, which makes the mail clients pick up the changes. Mostly.

However, famd kept running my server out of memory, so I had to turn it off. Back to the drawing board.


Did you ever find a workaround besides touching the folder? Quite a pain, isn't it? My setup is just like yours, except I do the arranging on an iPhone, and then the on the desktop never rechecks the IMAP folders until I touch them.


xrayspx's picture

I haven't yet. I went back to Thunderbird, with its own set of annoying issues (no sort by received date? Really?), but I've been thinking that this should be apple-scriptable, and then set that up as a task that runs every minute or something. If I do write something and it works, I'll post it up.

I should spend some time in front of my Macs tonight and see if I can make that happen. Unfortunately at the office I'm on a PC running Linux, so I can't do too much during most of the day.

I've been looking for a solution to this since Leopard came out. This used to work fine in Tiger. Any luck fixing this?

xrayspx's picture

I never actually had any luck with Tiger either, though it wasn't that big an issue to me at the time, so maybe I never noticed that it worked better. I was hoping Leopard would fix it, and I've been hoping for a fix in each point release.

Thunderbird has a tendency not to update exactly correctly either, but it's far more accurate than has been. I might sit down and play with some scripts this weekend and try and hack something together. Honestly though, the lack of a decent GPG plugin has forced me down the Thunderbird road even more.

Really anoying! Perhaps my problem is just a little bit different as i only have one mac (macbook) and Mail does receive new mail, filter them in specific folders (i can check via webmail interface that a mail has been moved by my filter on the macbook) BUT the "new mail count" does not update until i click on the folder or until i synchronize the imap account, this only happen with one of my 3 IMAP account ... and of course it's my work mail ...

Have you find a solution since? The smart folder trick does not work here!

christophe.laferriere (at)

xrayspx's picture

I think maybe it was down to the IMAP server I was using (UW-IMAP). I've changed to Courier IMAP over the weekend and in limited testing, it looks a lot better. Courier uses FAM on Linux to track changes made to a filesystem, and then send those changes in real time to multiple IMAP clients.

I'll have a better idea whether it did any good as I use it more regularly in the next couple of weeks.

Exchange as an IMAP server does a very good job of handling this. It does so well that I didn't notice that I only had the problem on my personal mail.

You might be off the hook Apple...This time at least.

That's exactly the script that I thought should exist but was too lazy to figure out how to write.

That will definitely work for anyone using UW-IMAP, if Courier + FAM runs into the same issues, I will definitely give this a try.

Anybody have a different location for that link above? It doesn't work..... I'd love to get that script ;-)


404, anyone have this?



xrayspx's picture

I'm sure I've got it around somewhere, I'll re-host it when I find it.

Any updates on this?

xrayspx's picture

Thanks for prompting me to update the article. I just recently turned of famd, so now I'm back to the Applescript hack way, I'll try and update with the progress of that too soon.

The thing is that it's hard to prove a negative, it's hard to show that running such and such script every minute on the Mac is making report read/unread correctly.