Migrating Mac OS X local mail to IMAP | Dafacto

The personal website of Matt Henderson.

Migrating Mac OS X local mail to IMAP

13 November 2015

To prepare for a possible clean install of the OS, I’ve been trying to move some local mail archives to the IMAP server, using Mail.app on OS X 10.11.1. Here’s how that’s going:

  1. I open the local “2004” archives folder in “On My Mac”.
  2. Select all message (about 8,000 messages in this folder)
  3. Drag them to the “2004” archives folder on the IMAP server.
  4. After a few minutes, I’ll see this:

What happened here is that while moving my messages, Mail hit one bad message.

This is so brain-dead. First, you’d think Mail could at least offer some kind of “Skip, and continue with the rest?” dialog (or just continue without one), but no… when it hits a bad message, it just stops the whole move process.

And what’s worse (or at least, as bad), is there’s no way to tell which message is bad, since the order in which Mail copies the selected message seems to be random!

As you can imagine, this makes the process of migrating mail so grueling and inefficient, that probably I’ll just give up.

Updates — I ended up not giving up, and here are some follow-up observations:

  1. A lot of sent mail messages from the years 2008 and 2009 wouldn't import because of an "invalid header". Inspecting these, I found lots of sent mail with the "from" header being ">From" rather than "From:". I have no idea how that happened, but a global search-and-replace using BBEdit on those .mbox folders in ~/Library/Mail/V3 fixed that.
  2. When I initiated a transfer of, say, 15,000 messages, they would all immediately disappear from the source folder in Mail, and then one-by-one begin to appear in the destination folder. Every now and then, Mail would crash during the process. On restarting Mail, however, the source folder was still empty, and the destination folder only showed, naturally, those messages that were copied before the crash. I have no idea what happened to the remainder of the messages that didn't get copied! To recover from this, I had to "import" the source .mbox files from backups, thereby creating some duplicate messages in the destination folder when repeating the mass transfer.
  3. Regarding the previous note, I'm wondering whether there's any utility that can scan a folder of messages, removing duplicates?
  4. In order to prevent a CPU meltdown during the process of moving all these messages, I had to temporarily disable MailTags 4.

Enjoy this article? — You can find similar content via the category and tag links below.

Questions or comments? — Feel free to email me using the contact form below, or reach out on Twitter.