views:

464

answers:

1

This appears to be a rare gem: where to find documentation on the structure of Apple Mail's .emlx files (and their partial variants, and the meaning of the directory structures). The docs do not appear to exist on Apple's site, nor can I find any reasonable mention of it via Google.

The point of this is the creation of a bash/ruby/python/insert-script-langauge-here script to convert a mess of these files into something usable/pliable, like Maildir or Mbox. The ultimate goal is to migrate a snapshot of a user's /Library/Mail store into an existing Dovecot setup, which uses a form of Maildir.

Yes, I am aware of this program but it does not address the solution I am after. Converting 20 mailboxes by hand and manually inserting them into an existing installation will require more hours than just writing a script that digests the messages into something else and then automatically storing them where they should be. Nevermind that there are potentially a half-dozen more users that will require this procedure. So it's worth my time to script it up.

Please vote to close the duplicate of this question while it is pending deletion, instead of voting for this question to close. For some reason, there are occasional posting glitches when using Chrome as a browser.

FOLLOW-UP: It appears that the format really is undocumented, and that most sources have reverse-engineered it. If I have time I will attempt to do so my self; and if I'm successful, I will post a 2nd follow-up with the details of my findings.

+2  A: 

Here is an emlx2mbox converter in ruby: Mailbox Converter.

I don't think it was written from any documentation of the spec, but it has undergone multiple updates, so hopefully evolved to handle at least some of the quirks of the format. The source code is about 250 lines long, and it looks readable and well-commented.

Matt G
While it is not documentation on the data structures, it is at least functional source code, +1 for a step in the right direction. :)
Avery Payne
The code does not produce any usable output? Argh! My eyes! The goggles! They do nothing!!!
Avery Payne
I suspect that there is no public documentation of emlx, since every emlx tool I've seen has indicated that they reverse engineered the format. If this rb doesn't work, I guess you get the honor of making a better version. :)
Matt G
Looks like that's where I'm at. But thank you for at least posting a tool that takes a crack at this. From what I can tell, there's a numeric indicator (size?), the message, and then some XML tagging at the end. I suspect that trimming the XML, ditching the numeric, and saving the remainder might do the trick.
Avery Payne