Importing MH-format mailbox

I don’t use Apple Mail or any commercial mailers. I use one derived from good old MH, which is still popular. In this format, each file contains a single email and there are many of these in a folder. Is there a script to import these emails to Devonthink Pro Office?



You could try to ‘cat’ all of these together with a linefeed between each and output the result to a file with a .mbox extension and try to import that one.

Thanks, that may work, but then I’ll also have worry about lines that begin with “from” and quoting them, etc. While I can make a simple Ruby script to handle such matters, it would be nicer if devonthink discloses its interface to the importing plug-in or if I can take messages directly into the database folders.

Why not set up your mh storage directory with the Import folder action so that each time a mail message is stored there, it will get imported?

It is quite simple: take the source of Pantomime and contribute MH support to the local mailbox parsing mechanism. It will be much easier for everybody who uses this framework then to use that format, this includes us, GNUmail and many others.

Well, I thought to get started on this so I wrote a ruby script to convert MH format to mbox format. I separated messages with extra \n as well as ^From (content of the From field)\n at the beginning of each mail in the mbox file. I also quoted out ^From and ^from appearing in the body. With such input, Devonthink can recognize individual mails in the Mail Importer when I set to Unix Mbox format and specify file. HOWEVER, when I click on Import All, I get an error popup message:

*** -[CWLocalFolder allSubFoldersWithMessages]: selector not recognized [self = 0xa7b54f0]

I get the same error even when I use real unix mbox file. I’ve tried a small mbox file as well as a big one. I also tried it on both Power Mac G5 and MacBook. Perhaps there’s some bug in mbox handling??

That is a bug, but if you click on “Import” instead it should work.

Actually, I tried it, but regardless of how I select individual messages, I seem to get 0 messages imported…

Then the format isn’t parse-able as an RFC822 mailbox. You could send me a couple of emails and I can see if it is easy to fix. No guarantees though. Please send them to

Actually, the problem looks like the database folder was broken. I deleted it, started with a fresh one, and it worked. Thanks.

Another problem is that, Japanese subject lines are sometimes broken. The mbox file I created is in JIS encoding (as it should be) but I bet some are MIME encoded and some aren’t. Do you know what encoding DTPO expects via mail importer?


If the subject lines are not properly encoded with the RFC standards, there is no guarantee what will happen. Pantomime uses ISO Latin 1 or even US-ASCII as the ultimate fallback.