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

gjabkup2#

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

gja@gjabkup2.space4me.com :install-mh
[...blah, created /home/gja/Mail as default mh mail location...]
gja@gjabkup2.space4me.com :

Now copy in my MH archives:

gja@gjabkup2.space4me.com : rsync -av <MHarchive>   /home/gja/Mail/
[...blah.. copied my email archive to ~/Mail/...]
gja@gjabkup2.space4me.com :

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

gja@gjabkup2.space4me.com :cd /home/gja/private/email97/
gja@gjabkup2.space4me.com :packf +personal/usa -mbox -file personal_usa_mh_mbox
Create file "/home/gja/private/email97/personal_usa_mh_mbox"? yes
gja@gjabkup2.space4me.com :

My local Thunderbird profile is at ~/.thunderbird/8fcun664.default/Mail/pop3.ureach.com/ 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:

gja@gjabkup2.space4me.com :cp personal_usa_mh_mbox ~/.thunderbird/8fcun664.default/Mail/pop3.ureach.com/mh-mail-pre97.sbd/
gja@gjabkup2.space4me.com :

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.

gja@gjabkup2.space4me.com :rm -rf ~/Mail/
gja@gjabkup2.space4me.com :

Leave a comment