Posts Tagged ‘Thunderbird’

md2mb.pl improved to better support migration from Kmail to Thunderbird

2012/04/11

It’s just incredible how the Open Source world works. You could never believe it before being yourself part of it.

It started with a simple poor small script I wrote for myself to support the migration of my kids to Thunderbird from KMail. And I blogged about it, as I thought it could be interesting as I didn’t found myself a working tool to do it.

It turned out it was the most read article of this blog ! Grumph ! I thought people could be interested by MondoRecue or Continuous Packaging, my bad 😉

Of course, when I have something to do, I prefer to write a script. Because old guy like me know perfectly you’ll have to do the stuff twice, and thus a script is useful !! And it was prooved again when I migrated my last kid with it again. And the script was improved at the same time. But I knew there were still some flaws, as one colleague found it as well, and had an issue with it (some mails not seen correctly even if imported in subfolders) !

So last month I received feedback from another user, who took that script and improved it greatly, fixing btw the above mentioned problem. And so that small script has now as many contributors as Mondorescue and twice as many as project-builder.org.
Edward Baudrez did a great job to improve the script, adding lots of CLI options capabilities to make it more versatile, fixing mail import in subfolders, error message handling, adding POD doc, …

I still have one or two improvements I’ll discuss with him to try making it even better, but that’s already quite an interesting piece of code !

So as it’s now even more useful than before, those interested by that migration should download and test it in their environment, and continue to send patches 😉 and make me more mazaed by the power of our community, for large as well as small stuff !

Migrating from KMail to Thunderbird: The revenge

2012/01/08

After migrating 2 of my kids and my wife from Kmail to Thunderbird last year, I finally decided this week-end to finish the last migration for my first daughter on her Mageia distribution.

I previously made unsuccessful tries, as her environement was different, with many more subdirectories, and special chars, so it didn’t work with the previous version of the script.

Now with the revisions 1389 and 1390 of the md2mb.pl script, I have successfully migrated her environment, without any manual intervention.

Hopefully, seeing the number of times the previous post was looked at, it will be again useful (even more now that it works better:-)) for others. I even clarified the license in revision 1391 for you to use more easily.

Happy migration !

Using Thunderbird as default mail reader with KDE4

2011/01/13

Just a small hint (this page serves as a reminder for me mainly) for using Thunderbird as default mail reader with KDE4. You may run the systemsettings command (or click on it in the KDE panel), select the mail client entry and type the following line for thunderbird:


/usr/bin/thunderbird -compose "subject=%s,cc=%c,to=%t,attachment=%A"

Works like a charm here. Reference doc is at https://developer.mozilla.org/en/Command_Line_Options and also by letting the mouse over the text box where you have to pass that text.
Typically OpenOffice.org which uses on Mandriva 2010.1 by default the xdg-menu entry for the default mail reader just does the right thing when ask to send by mail the current document.

Migrating from KMail to Thunderbird

2011/01/10

This week-end, after passing too much time to try to understand contact management in KMail (which was working quite well in KDE 3.x but is completely flawed IMHO in KDE 4.x), I decided with my wife it was time after 8+ years to try another mail reader.

Thunderbird was of course the first candidate, due to the familiarity she had with Firefox, Outlook (at school) and the fact it’s not that different from KMail anyway in its behavior and interface. I must say I was impressed to see my wife just say that she didn’t mind changing Mail reader, in order to get lacking features. Probably her familiarity with Open Source has also created an open mind for computing programs, and the fact she already uses multiple tools without major issue, makes her willing to try new ones.

So I started to work migrating her data from KMail to TB. I found a small program in order to help md2mb.pl. However, it was far from being complete, and I decided to rewrite a new one, based on the ideas from the other one, in order to have a better migration support. So here is a new md2mb.pl which hopefully will be useful for others as well.


#!/usr/bin/perl -w
#
# Program to import a maildir kmail environement into a thunderbird one.
# (c) Bruno Cornec under the GPLv2.

use strict;
use File::Find;
use File::Copy;
use File::Basename;
use File::Path;

my $cmd="formail";
# CHANGE AS YOU WISH
my $oldroot = "/beatrice/.Mail.sav";
my $newroot = "/beatrice/.thunderbird/30cq2rn3.default/Mail/Local Folders/";
# Is the newroot a file (1) or a dir (0)
my $nrisfile = 0;
my $debug = 0;
# END CHANGE

$debug++ if ((defined $ARGV[0]) && ($ARGV[0] eq "-v"));
print "DEBUG MODE, not doing anything, just printing\n" if ($debug);
if ($debug) {
print "CMD1: mkdir -p $newroot\n" if ((not -d "$newroot") && (not $nrisfile));
} else {
mkpath("$newroot",0, 0755) if ((not -d "$newroot") && (not $nrisfile));
}
system("$cmd /dev/null 2>/dev/null") == 0 or die "cannot find formail on your \$PATH!\nAborting";

find(\&md2mb,($oldroot));

sub md2mb {

if (-f $File::Find::name) {
return if (
($File::Find::name =~ /\.ids$/) ||
($File::Find::name =~ /\.sorted$/) ||
($File::Find::name =~ /\.index$/) ||
($File::Find::name =~ /\/cur\//) ||
($File::Find::name =~ /\/new\//) ||
($File::Find::name =~ /\/tmp\//));
}
if (-d $File::Find::name) {
return if (
($File::Find::name =~ /\/cur$/) ||
($File::Find::name =~ /\/new$/) ||
($File::Find::name =~ /\/tmp$/));
}
if ($debug) {
print "CURR: $File::Find::name\n";
}
my $destname = $File::Find::name;
$destname =~ s|^$oldroot||;
$destname =~ s|\.([[:alnum:]éèçàù\s]*)\.directory|$1.sbd|g;
if ($debug) {
print "DEST: $destname\n";
}
my $cdir = dirname("$newroot/$destname");
my $outputfile="$newroot/$destname";
$outputfile="$newroot" if ($destname =~ /^\s*$/);
if (-d $File::Find::name) {

my @files = (,);

if (@files) {
if ($debug) {
print "CMD2: mkdir -p $cdir\n" if (not -d "$cdir");
} else {
mkpath("$cdir",0, 0755) if (not -d "$cdir");
}
}
foreach my $file (@files) {
next unless -f $file; # skip non-regular files
next unless -s $file; # skip empty files
next unless -r $file; # skip unreadable files
$file =~ s/'/'"'"'/; # escape ' (single quote)
# NOTE! The output file must not contain single quotes (')!
my $run = "cat '$file' | $cmd >> '$outputfile'";
if ($debug) {
print "CMD3: $run\n";
} else {
print "Copying maildir content from $File::Find::name to $outputfile\n";
system($run) == 0 or warn "cannot run \"$run\".";
}
}
}
if (-f $File::Find::name) {
if ($debug) {
print "CMD2: mkdir -p $cdir\n" if (not -d "$cdir");
print "CMD3: cp $File::Find::name $cdir\n";
} else {
mkpath("$cdir",0, 0755) if (not -d "$cdir");
copy($File::Find::name,$cdir);
print "Copying mailbox content from $File::Find::name to $outputfile\n";
}
}
}

Warning: this code doesn’t work from the blog as wordpress makes some modifications, so download it from here

Run it first with a -v option in order to see what will be done. Be careful as I’ve just fixed the problems I had on my side, but probably not all of them. Especially, take care of file names with “‘” in them. they won’t work well.

So migration has been done, and of course more re-organization of the mailboxes. But now everything works fine, including contact management (that were imported using the LDIF exchange format).

And my wife has already sent a couple of mails, so I guess it will not take her long to be very familiar with TB.

Once again this shows all the power of FLOSS: freedom of choice, no info hidden, open format, and voilà.