My work, or University as a whole, has two email systems. One linux based, using Dovecot and Sendmail, and the other being Exchange 2013. In an effort to “simplify” things, IT units around campus are being tasked with migrating all employees over to Exchange. Since I had been doing this on my own for a while, when the call went out officially, I only had about 60 users to do. Sadly, of those 60 or so, 3 of them were using POP3 and Mail.app. After beating my head against a wall trying to automate this migration, I finally just did it manually for one user. Except then, a problem arose.
Apple Mail (Mail.app) uses the filesystem date/time as the “Date Received” in views. It doesn’t use the header in the message (that header is instead reflected in “Date Sent”). So all the mail I manually copied over had the wrong “Date Received” (it moved to the day I did the migration, not the date it was actually received). =(
Sadly, though, the solution isn’t free. I purchased an application called Emailchemy to do the worst part. The only other tool I used was imapsync to migrate the email. Here’s the basic workflow. Based on how we do migrations, this will be the quickest way to get them receiving new email while the rest of the stuff runs in the background.
Quit Mail on the users computer, and then go to ~/Library and copy their “Mail” folder to their desktop. I used a 2nd machine to do the conversion so they could use their machine without problem (and I could easily have a working copy of imapsync, but YMMV). Once that’s done, go into Internet Accounts and delete their pop3 account, and add their Exchange account. Now, at least, they’ll start getting new email.
From Emailchemy, using the Basic Conversion, point it at their Mail folder on the desktop, and save it as an imapserver file. Emailchemy has a nice builtin IMAP server for just these kind of occasions. Once that conversion is done, you can then go to “Tools” in Emailchemy, and “IMAP Import Server”, point it at your exported file/directory, and “Start”.
Now, using imapsync, you basically just need to point it at the local Emailchemy IMAP server, and your exchange server (make sure IMAP access to Exchange is enabled). Because of few of the messages on this user’s POP account were poorly formatted, I had to up the errormax in imapsync to 1000 or so. But here’s the basic command.
./imapsync --no-modules_version --errorsmax 1000 --noreleasecheck --noabletosearch --maxsize 26214400 --disarmreadreceipts --nolog --host1 localhost --port1 8143 --user1 "import" --password1 'mymail' --sep1 "|" --host2 exchange.example.com --ssl2 --user2 "username" --password2 'password'
The important bits are really “disarmreadreceipts” (Exchange issue) and “noabletosearch”. Without that, imapsync wouldn’t pull the emails from Emailchemy. It’s not really a documented option, so I’m not exactly sure what it does. Migration does take a while, and afterward, you may need to move some messages between mailboxes to match up with how things should look (For example, in my case, it put all the Folders in a Converted/Mailboxes subfolder, and the main Inbox, Sent, etc into [email protected]). So, things will need a little cleanup after the fact. =) Still, it works, and it doesn’t require a lot of handholding like a manual migration does. And while I don’t understand WHY Mail.app uses the filesystem date as the “Received Date” unlike every other email client, this also addresses that.
Good luck, and feel free to leave a comment if you have questions. I’m off to migrate the other two users.