From (broken) KMail to Evolution (or from maildir to mailbox)

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 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 ./ "{}" ";"

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 ./ "{}" ";"

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 ./ "{}" "$a.mbox" ";" ;

and, because there where hidden directories:

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

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.


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