What format does Apple Mail store its emails in?

We're trying to convert a user's email mailbox from Apple Mail to Outlook 2010.

We copied the files off the mac, and they are mostly directories that end in .mbox and contain a folder called Messages containing .emlx files.

The .mbox extension on the folders initially made me think that these messages were in the mbox format, but after some research I found that the mbox format is actually a single file, so that rules out it being in that format.


The vengefulcow site's code is nice, but needs a slight modification if you're messing with newer OSX mail.app versions and imap mailboxes, here's a unified diff:

$ diff -u emlx2mbox/emlx2mbox.rb emlx2mbox-works/emlx2mbox.rb
--- emlx2mbox/emlx2mbox.rb      2006-12-13 12:02:41.000000000 -0500
+++ emlx2mbox-works/emlx2mbox.rb        2014-02-16 01:28:38.775293976 -0500
@@ -56,7 +56,7 @@
     # Compile messages in mbox directories.
     mbox_dirs = Dir.entries(source_dir).find_all do |entry|
       File.directory?("#{source_dir}/#{entry}") and
-      (entry[-5..-1] == ".mbox")
+      (entry[-9..-1] == ".imapmbox")
     end #find_all
     mbox_dirs.each do |dir|
       if File.directory?("#{source_dir}/#{dir}/Messages")
@@ -68,7 +68,7 @@
     subdirs = Dir.entries(source_dir).find_all do |entry|
       File.directory?("#{source_dir}/#{entry}") and
       entry[0, 1] != "." and
-      entry[-5..-1] != ".mbox"
+      entry[-9..-1] != ".imapmbox"
     end #do
     subdirs.each do |dir|
       self.convert_mailboxes("#{source_dir}/#{dir}", "#{dest_dir}/#{dir}")

You can find a description of the format based on an reengineering effort here:

It has three parts:

  1. The length of part 2, in bytes
  2. The message itself
  3. Message metadata (XML Property List)

There was a question on Stack Overflow where the answer linked to a program to convert to mbox format.

It appears to be proprietary and therefore not well documented in the public domain.