Migrating from KMail to Thunderbird

The last few years (I don't really remember how many) I've used KMail as my e-mail client in my Gentoo Linux box. At work, where I have to use Windows, I use Thunderbird, Mozilla's e-mail suite. Both are excellent programs, but some things regarding KMail made me leave it behind and migrate to Thunderbird in Linux too.

Some of the reasons for this decision is that KMail 1.x is not maintained anymore (other than small bugfixes maybe?). I tried to migrate to KMail 2 last summer, but the experience was painful at the time. The migration to version 2 was ok, but with all this Akonadi stuff, I started having huge files at my home directory because of the indexing process and the application itself was sluggy. I also lost a few messages, fortunately not a big loss. So, I went back to KMail 1.x at the time (I kept backup, I used version 2 for a day or something). However, I see that Thunderbird is actively maintained and more features are added to the suite.

In this post, I will explain how to migrate all your messages from KMail to Thunderbird.

Some introductory stuff

KMail uses the maildir format to store its messages. Practically, each message is saved in a separate file and there are a few index files along with each directory (folder in the KMail view). On the other hand, Thunderbird uses the mbox format. Each folder is actually a big file, a concatenation of all the messages that the folder has. I guess each method has its ups and downs, but this is something out of scope for the current post.

The KMail version I used until now is 1.13.7, while Thunderbird is 12.0.1.

The migration process

It's 99.9% possible that you use the maildir format for KMail. You can always change to mbox, but you have to explicitly do this while creating a new folder. Thunderbird does not offer such an option. By default, it uses the mbox format.

After doing some Googling, I found out various posts regarding KMail to Thunderbird migration, but none of them seemed not "dangerous" or rock solid. Then, I came across to this forum, where a user simply explains that creating a new folder in KMail with the mbox format and simply copying all messages there will do the trick! And then, I realized that this should work. And it did.

What I did is to create two folders using the mbox format, one for the incoming messages (inbox) and one for the sent messages. I then copied all inbox and sent messages in each corresponding folder (depending on the number of messages in each folder, it should take some time, not too much though) and then, I was ready to copy the mbox files to the Thunderbird profile directory.

What happens when you have subfolders in your folder messages? If for example, you have a folder named Linux and a folder under it named Gentoo, then, in KMail mbox format, you will have a Linux file in the filesystem and a .Linux.directory directory. The first in the folder Linux with all its messages, while the second is the directory that holds any folders under Linux (in this case the Gentoo folder). In this folder, you will have a Gentoo file that holds all messages under the Gentoo folder.

Thunderbird uses a similar structure. In the example above, it would have a Linux file and a Linux.sbd directory that will hold the Gentoo file (the Gentoo messages folder). So, what you must do is to copy the Linux file and its corresponding .Linux.directory directory under Thunderbird's profile folder and rename .Linux.directory to Linux.sbd. You must rename all the .<name>.directory directories to <name>.sbd and you should be set. When you are finished with all your folders, fire up Thunderbird and after a few seconds to create its indexes, you should be ok. Thunderbird's index files are files ending in .msf.

In each .Linux.directory directory, KMail stores some other index files (ending in extensions like .index). You are free to delete them, Thunderbird won't need them.

So, by simply transferring all your messages in KMail from the maildir format to mbox and copying the underlying system files under Thunderbird's profile you will have migrated all your messages to Thunderbird. Of course, other things like KMail rules must be created by hand in Thunderbird. The address book can be exported in a comma separated file (.csv) and imported to Thunderbird easily. No hacks, no third-party scripts and you are done. Of course, in all cases, before initiating the procedure, BACK UP your files!


So, migration went fine. I'm using Thunderbird at the moment. The migration had some cons, like losing KMail's integration with KDE and using the filtering system in Thunderbird, which is inferior to KMail's. But, other than that, I'm happy.

I hope you found this post useful. Feel free to ask anything you'd like.

υπολογιστές / computers: 
Χρήσιμο / Useful: 
Average: 3.3 (26 votes)
Ψηφίστε για την ποιότητα του άρθρου / Vote for the article's quality


Do you know how much Hard Disk space did you save (~%) after migrating to Thunderbird? In my case, I belive, Aconadi indexing takes up huge amount of disk space, in regard of my 6000 Kmail messages.

Since I went back from KMail 2 to KMail 1.x, I deleted any Akonadi indexes that were created while upgrading to KMail 2 at first, so my mail folder went back at the initial size. No, I did not compare the folder size from KMail to Thunderbird, but I suspect the difference is a few tens of MB (my mail folder is ~ 3GB at the moment).

Today I migrated from Kmail (KDE 4.7.2 (4.7.2) "release 5") to Thunderbird (12).
I have many many subfolders in Kmail.
Here is how I did it:
1) In Kmail: a. Click a mail folder, b. select some (or all) messages (Ctrl+A), c. click Kmail > File > Save as... d. gave a name (e.g. inbox) e. click Save.
This creates inbox.mbox containing the mails I wanted.
2) Repeat (1) for all folders and subfolders of Kmail I wanted.
3) Remove .mbox extension from all mboxes.
4) Move all mboxes to Thunderbird mail folder (e.g. /home/myname/.thunderbird/jrz1weeq.default/Mail/pop.provider.com/)
5) Refresh Thunderbird (close and reopen).
That's all.
PS: Addresses export and import through LDIF (or CSV or VCF). Filters, only manualy one by one, sadlly. Identities, POP's and SMTP's also manualy.

Well, I guess that the procedure you followed is more or less the same as mine.

At the end, the moral of the story is that you can migrate from either client to the other one rather painlessly and this is good.

Yes, filters and accounts were manually added, that's sad. And I prefer KMail's filters, they are much better than Thunderbird's. Another annoying issue with Thunderbird is that while you close its window, the process stays there, you have to kill it by hand in case you need to open Thunderbird again, since it complains that it's already open. It's a bit annoying, so I hope they fix it.