Importing MH email archives into Thunderbird

I recently decided to resurrect some personal email archives from the 1990s. Back then I used an email client that saved messages in the ‘MH’ mail box format. Today I use Thunderbird under FreeBSD. Inspired by this page, I’m summarising here how I imported my old MH emails into Thunderbird. (This is of archival value to me. And possibly useful to you, if you’re reading this and you’re not me.)

Short version

Use the packf command from the nmh mail system (available in the FreeBSD Ports tree under /usr/ports/mail/nmh) to convert mh folders into mbox files, then manually import the resulting mbox files into a suitable Thunderbird .sbd directory.

Install NMH

I used portmaster to install nmh:

gjabkup2# portmaster /usr/ports/mail/nmh
===>>> Port directory: /usr/ports/mail/nmh
===> Cleaning for nmh-1.3

===>>> Installation of mail/nmh (nmh-1.3) complete


Utilise packf

The general syntax for converting MH to mbox is:

% packf +SAVED -mbox -file SAVED_mbox

where SAVED refers to an existing MH mailbox, and SAVED_mbox is the target mbox file you’re going to create (containing all the emails from the SAVED mailbox).

First, run install-mh to configure a local MH mailbox system :install-mh
[...blah, created /home/gja/Mail as default mh mail location...] :

Now copy in my MH archives: : rsync -av <MHarchive>   /home/gja/Mail/
[...blah.. copied my email archive to ~/Mail/...] :

Now I can run packf on the nmh folders under ~/Mail/personal to create a number of mbox equivalents. The following example takes the MH folder (mailbox) personal/usa and converts it into a single file personal_usa_mh_mbox :cd /home/gja/private/email97/ :packf +personal/usa -mbox -file personal_usa_mh_mbox
Create file "/home/gja/private/email97/personal_usa_mh_mbox"? yes :

My local Thunderbird profile is at ~/.thunderbird/8fcun664.default/Mail/ and I’ve created a Thunderbird folder called mh-mail-pre97 in which to store my converted mailboxes. Copy the new mbox file into the target folder: :cp personal_usa_mh_mbox ~/.thunderbird/8fcun664.default/Mail/ :

Fired up Thunderbird, and voila! The newly created mbox version of my old mh folder is properly recognised by Thunderbird as a new email folder.

Remove the temporary mh mailboxes

After doing the conversions, the NMH mail directory under /home/gja is no longer required so I removed it. :rm -rf ~/Mail/ :

One comment

  1. This was useful, thank you. As claws seems to be permanently tied to webkitgtk for html rendering I needed to change client but had been putting this off for ages because I remember the last time I changed client and the grinding tedium of broken/inadequate/non-existent import/export/convert tools, and the mind bending documentation of what did exist. Your article brought some clarity to the mysteries of nmh and packf and I got the job done nicely with find, bash pattern matching, while and so on. Goodbye claws!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: