Migration to mbox from Mailsmith’s native format

43 views
Skip to first unread message

GlennFleishman

unread,
Jul 10, 2021, 12:36:07 PM7/10/21
to Mailsmith Talk
Folks, my final post on this group! After about 20 years, I migrated from Mailsmith to Postbox, the only mail client I have found I can really stand to use. I had tried a few times to do a full export using an AppleScript posted here long ago, but despite rebuilding my Mailsmith Mail data, it never completed and seemed to have problems, too. I upgraded my main Mac to Big Sur and had a Parallels instance of Mojave running to keep Mailsmith alive. Then my main Mac died and I was left with only my M1 Mac. D'oh! 

In examining the nested folders with .msgd data and then performing a test, I realized that Postbox at least was liberal enough in accepting variations in imports that I could simply concatenate all my .msgd files into one fax mbox file per folder and import those. It went nearly perfectly. I am posting the perl script below in case it's of interest. There was probably more parsing I could have done, but given that I got nearly 500,000 messages moved into Postbox in a matter of minutes and then indexed in about an hour in the background, I'm pretty pleased with the outcome.

You could further refine the output naming scheme. Postbox imports an .mbox file (which appears like a directory in the Finder) with the full name, so "inbox.mbox" becomes "inbox.mbox" as the folder name. Make sure your output directory in the $out variable exists before starting.

Thank you, Rich and Patrick for stewarding this great app through for so many years and into retirement! I will miss it.

#!/usr/bin/perl
$| =1;

my $d = "/Volumes/Minimal Speedable - Data/Users/glenn/Mail/Mailsmith User Data/Mail";
my $out = "/Users/gif/Documents/Mailsmith Export";

&recur($d);

exit 0;

sub recur {
my $d = $_[0];
opendir(my $dh, $d) || die "can't opendir $some_dir: $!";
my (@files) = grep { !/^\./ } readdir($dh);
closedir $dh;

# concat mbox file
my $mbox;
my $mbox_name;
foreach my $f (@files) {
# find directories 
if (-d "$d/$f" && $f =~ /\.messageData$/) { 
&recur("$d/$f"); 
print "$f: ";
}
$d =~ /\/([^\/]*?)\.messageData\/?$/;
$mbox_name = $1;

# check for .msgd
if (-f "$d/$f" && $f =~ /\.msgd?$/) {
open (IN, "< $d/$f"); 
my $text;
open(my $fh, '<', "$d/$f") or die "cannot open file $d/$f";
{
local $/;
$text = <$fh>;
}
close($fh);
$mbox .= $text;
print ".";
}
}

# write mbox file
if ($mbox) {
print "\n";
open (OUT, "> $out/$mbox_name.mbox");
print OUT $mbox;
close OUT;
}
}

Reply all
Reply to author
Forward
0 new messages