If you are looking for a rant about how Evolution is better than KMail, look elsewhere. I am running Evolution because I am giving Gnome another chance and I like using all the standard tools to get an integrated desktop.

Either my mails becamepre> corrupted or KMail on Ubuntu 7.04 is not as stable as it was before before because KMail kept crashing before starting. Which means I couldn’t use the usual way to export mails from KMail to Evolution: create an mbox folder, copy all the mails to the mbox folder, import the mbox folder into Evolution.

To workaround this problem, I went to the directory where KMail’s mail is, which in my case was “~/.kde/share/apps/kmail/”. There I created a script called mdirmail2mbox.sh that contained:

#!/usr/bin/env bash

echo "Processing \"\""
cat "" | formail -ds >> mbox

Evidently, the biggest task is in ‘formail’, which is part of procmail. This is a throw-away script with hard-coded values like the output file “mbox”.

Since I wanted to separate the mail I’ve received from the mail I’ve sent I first exported the more-than-15000 sent mail using this command:

find mail/sent-mail/ -type f -exec ./mdirmail2mbox.sh "{}" ";"

When that finished, all my sent email was in the file called “mbox”. It took a long time:

$ ls -la mbox

-rw-r--r-- 1 pupeno pupeno 635364913 2007-05-14 04:35 mbox

Importing into Evolution took even more. What I didn’t like about it
is that Evolution tries to guess what’s the type of the file you are
importing, to guess that it was an mbox file it took more than 5
minutes in which it consumed a lot of CPU and the whole application was
freezed. Doing the import itself also took a long time, but this was
expected by me and by Evolution’s developers which where kind enough to
put a progress bar.

To be able to run more processes in parallel what I actually did is
rename the mbox file (“mbox”) to “mbox-sent-mail” and move away the
sent mail (to “mail.import/set-mail” next to the “mail” directory) to
export the rest of the email. I’ve run the export of the whole mail:

find mail/ -type f -exec ./mdirmail2mbox.sh "{}" ";"

and then the import of the mbox-sent-mail into Evolution. I’ve
imported it into a separate folder to avoid mixing it up with the rest
of my email that was currently en Evolution.

At this point I went to sleep. All the sent-mail were imported
successfully and the rest of the mail where turned into an mbox as well:

$ ls -la mbox*
-rw-r–r– 1 pupeno pupeno 829090740 2007-05-14 05:49 mbox
-rw-r–r– 1 pupeno pupeno 635364913 2007-05-14 04:35 mbox-sent-mail

I was expecting the received mail to be in the 2GB range rather than
the 0.8GB. I hope it was exported correctly. Now all I need is to
import that mbox into a folder in Evolution and run my filters (for all
mailing lists, people, etc) on all those mails and then sort manually
(or create more filters) for the rest. I’ll put the import tonight so
it’ll be done while I am sleeping and not using the computer.

Some time latter

Of course that didn’t work. I couldn’t reach the importing process,
Evolution crashed first. Another solution is needed. I’ve changed the
script to be:

#!/usr/bin/env bash

echo "Exporting \"\" to \"\""

cat "" | formail -ds >> ""

and moved it into the “mail” directory. There I’ve run:

for a in * ; do
    find "$a" -type f -exec ./mdirmail2mbox.sh "{}" "$a.mbox" ";" ;
done

and, because there where hidden directories:

for a in .[a-zA-]* ; do
    find "$a" -type f -exec ./mdirmail2mbox.sh "{}" "$a.mbox" ";" ;
done

and ended up with a bunch of smaller mboxes which where importable. I am not yet sure wether all this worked or not, but I hope that this may help someone with a similar problem to mine.

You may also like:

If you want to work with me or hire me? Contact me

You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 5,047 other subscribers

I wrote a book:

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I’ve been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git ham radio history idea Java Kubuntu Lisp management Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek technology Ubuntu web Windows WordPress

I’ve been writing for a while:

Mastodon