##### Setting the context
I run Mail.app on an internet-hosted Mac mini, in order to provide [server-side spam filtering](/2012/08/11/running-your-own-server-side-spam-filter-with-spamsieve/) and to pre-process my email based on an extensive set of rules.
Many of those rules involve the application of tags to messages, via the wonderful [MailTags](http://www.indev.ca/MailTags.html) plugin.
On the MacBook Air that I use at home and at work, I have a _simple_ set of four rules that apply account-specific colors to incoming messages. On the other hand, that MBA does contain an extensive set of Smart Mailboxes, most of which search for messages containing certain tags.
##### Problems archiving and deleting inbox messages
I’ve been having awful problems recently with Mail.app’s ability to delete and archive messages in my inbox. I’ll archive a message, only to see it return 10 minutes later. I’ll archive it again, and it’ll again return sometime later.
If I then view my inbox on an iPad, however, I’ll see *four* copies of that message in the inbox! If I then delete them all from the iPad, the pesky original message will then be removed from the inbox on the Mail.app.
This has been driving me crazy!
##### An aside—Why am I seeing four copies?
Mail.app on OS X has an annoying behavior of only showing you _one_ copy of duplicate messages; so in fact, there are _four_ copies of the message in the inbox, but Mail.app is only _showing_ me one.
That’s how four messages somehow get created. The first time I archive the message, a second copy gets created. The second time I try to archive, _two_ additional copies get created.
##### Disappearing Smart Mailboxes & Rules
In an attempt to fix this irritating behavior, I uninstalled the MailTags plugin, which is currently in a beta version for OS X Mavericks. Most probably MailTags has nothing to do with it, but since it’s _beta_ software, I thought I’d give it a try.
After uninstalling MailTags on my MacBook Air and launching Mail.app, I observed my entire list of Smart Mailboxes simply disappear—replaced by a single Smart Mailbox, “Today”. Re-installing MailTags, all my Smart Mailboxes returned.
After uninstalling MailTags on the mini and launching Mail.app, I opened the preferences to find all my rules gone, and replaced with the four simple rules I have on my MacBook Air!
So, obviously there’s some syncing going on, and obviously MailTags is somehow involved as well.
##### What’s going on here?
I emailed the folks at MailTags, and learned that MailTags keeps its own local database of Smart Mailboxes and Rules, so that if you launch Mail without MailTags installed, no rules or Smart Mailboxes will get created that contain tag-related rules.
Ok, that explains why things change when MailTags is uninstalled.
What’s strange, though, is that before uninstalling MailTags, I’d removed all the tag-related criteria in my various Smart Folders, and _still_ they all disappeared after uninstalling MailTags. So, evidently, once a Smart Mailbox (or rule) makes its way into the MT local database (because of tag-related criteria), it’s _not_ moved to the local Apple database if you later remove those tag-related criteria.
##### iCloud’s role in the mess
How is syncing entering the picture?
I did some research and learned that if you have Documents & Data enabled in iCloud, any Mail.app rules and Smart Mailboxes you create will get synchronized across _all_ your Macs.
That’s terribly undesirable behavior for someone like me, who specifically needs different sets of rules and Smart Folders running in Mail.app on each of my Macs. And according to [this article](https://discussions.apple.com/thread/4139722) the only way to stop this behavior is to disable Documents & Data in iCloud.
I was going to do just that, when I saw 1Password in the list of apps using Documents & Data—and that’s the _one_ app that I _need_ to sync data across all my apps. So unless I’m willing to move 1Password syncing back to Dropbox, it looks like I’ll be stuck with syncing of Mail rules and Smart Mailboxes.
Unless… I keep MailTags installed. Remember, when MailTags is running, Mail.app’s Smart Mailboxes and rules are created from _MailTags_ local database, which is _not_ synced.
But with MailTags running, I’ll not be able to figure out whether it’s playing a role in my inability to delete/archive certain messages from my inbox—which is where this all began. So I’m kinda stuck.