Every couple of days Mail.app stops showing the unread message count on the Dock icon. Restarting the application brings it back immediately.
In Preferences->General, I have Dock unread count linked to a smart mailbox that excludes a handful of folders.
Is this a known issue, and is there a fix?
The problem just recurred, and I notice that when I open the smart mailboxes list, the mailbox I have Dock unread count linked to also doesn't show an unread count, even though viewing the smart mailbox contents has some messages marked as unread.
So the problem seems to be related to how unread counts are calculated for smart mailboxes.
I've reopened the question. Things were going pretty well for a few days with the solution I posted in the answer. But today I'm seeing the opposite problem: the Dock count is 3, but there are no unread messages in any of the folders that are supposed to be counted. When I view the smart mailbox, it's empty. And marking messages as unread adds them to the smart mailbox, but the badge in the dock doesn't change.
As in the past, restarting Mail corrects it.