Thunderbird: Import mail from Kmail

I think I have used Kmail for at least ten years, but now I give up. I have used Kmail2 for more than a year, but it just doesn’t work. I think this is the worst Linux application I ever have ever used – probably a KDE-killer application. I can’t get Kmail1 back, so now I migrated to Thunderbird. One practical aspect of this: How do I transfer mail from Kmail to Thunderbird?

Kmail and Kmail2 store mails in maildir format, one file for each mail, under e.g. ~/.local/share/local-mail/. Subdirectories correspond to mail folders (inbox, sent mail etc.). Each mail folder directory again has three subdirectories: cur, new and tmp. You will probably find all mail under the cur-directory. If you have Kmail in a usable state, you can save all mailfolders one by one from the menu: folder -> archive folder.

To prepare import to Thunderbird, copy the mail folders somewhere, either by regular file copy from the mail directories or by archives, and then run the following script in each cur-directory

#!/bin/sh
mkdir ../eml
d=*
for i in $d
do
    cp $i ../eml/$i.eml
done

This script creates a new eml-directory, copies and renames each file with an eml-extension. Instead of this script you can also run the command line one-liner:

mkdir ../eml;d=*;for i in $d;do cp $i ../eml/$i.eml;done

Now it’s time to import the eml-files into Thunderbird. First install the Thunderbird extension
ImportExportTools. Go to each folder you want to import to, e.g. inbox. Right click on the folder in the mail folder list to the left and select Import/Export -> Import all messages from a directory and choose the corresponding eml-directory. You repeat this for all your eml-directories.

If the Kmail used Kwalletmanager for your external email account passwords you can find them by looking up the accounts under kmail -> Passwords. Each account is given by a integer number. To find out which number corresponds to which account you can open ~/.kde/share/config/kmailrc. There you will find the account names and the associated numbers.

7 Responses to “Thunderbird: Import mail from Kmail”


  • Thanks for the tip. I’m trying it now.

    I’ve been with Kmail for years as well, and it’s with great sadness that I too am finally resolving to quit. I have nothing against Thunderbird, in fact I quite like it, but I was staying with Kmail because it really could be such a great application. But it’s just so horribly buggy. I can’t take any more ‘broken resource’ error messages, any more backend changes that require my entire email history to be re-imported (to the same application!), and on and on. Time to quit.

  • Thanks for the write up. Worked for me.

    I have been using kmail for about ten years and finally gave up. It is now a substandard product, buggy, unresponsive, and contrary to the previous linux/unix philosophy of one good tool for one job. Now it is tied to the symantic concept through akonadi, which seems to have been born broken and broken is in its genes. Have lost mail to many times to continue to wait for a usable and dependable mail client.

  • kmail seems to work these days. I totally agree with all the nepomuk/akonadi/kdepim naysayers – the developers broke it, then released it. The arrogant ****s have taken it away from us techies to try to compete at the bottom: with windows.

    They’ll be giving us a registry, next, but back to kmail: I wish I could work out how to have simple sorted by date, threaded views, without the windows-inspired “today”, “yesterday”, “last week” space wasting separators (I display the date in the list, and usually know what date it is today). I reckon some new developer though “how cool to work out when “last week” was”, and put it in. T*****s!

  • Still very useful in 2015! Thanks a lot, with your help it took only a few minutes to import about 10 years of mail from kmail into Thunderbird. 🙂

    I really liked kmail, but while the whole akonadi thing is a fascinating piece of technology, I finally decided I don’t need the functionality it provides and got better use for the RAM.

  • July 13 2015 on OpenSuSe 13.2
    Nice little script, very useful, I even got the attachments
    Worked a charm.
    I used Kmail on my old OpenSuSe 11.2 but it was too unpleasantly buggy.
    Time to change. Thanks for your help.

  • Still working 2016 with thunderbird 45.3.0 (on Mint 18 and Cinnamon) and with an old Kmail-folder used since 2005 (and happily backuped in Dezember 2015).

    the one-liner worked out of the box and the eml subdirectories had been created fast.

    Anyhow, I had some strange occurences importing them, that I want to share (infos are translated into english as I use a german system)
    – I needed to search the “Thunderbird ImportExportTools” with google, download it locally and then to install it via “extra->addon/ -> /Install from file (last one kind of hidden 🙂
    [I did not find it with the thunderbird -search function within the “addon” feature. Maybe me :)]
    – I needed to create a “new” mail account, as the export-import tool did not import to “local” (checking “local” it says, it does not exist, so, there might be some issues on my side updating from mint 17 to mint 18) – anyhow, after i created a second email-account (the “first” is an IMAP one since 2016), the importexport tool started to react properly (before, it did nothing at all while trying to import).
    – I created the sub folders “inbox” and “sent” in the second account, right-clicked on “inbox” and then went for “import/Export”->import all mails from a folder->including subfolders and searched for the kmail-inbox folder “inbox” (not eml, but above) finaly imported all old Emails. (same with “sent”).

    Nice explanation and thanks!

  • Many thanks for this script.
    I fully agree. Used kmail for almost 10 years.
    Right now there are some serious issues, still not fixed.
    Because devs don’t wont to, or it has not enough priority:
    – HTML mail composer: it is not possible to resize the embedded image
    – poor handling of lists when composing mails
    – hiDPI support when displaying an email: when clicking on a link the whole panel gets messed up and I have to restart kmail
    – printing of emails: I have to use the browser …
    – akonadi: sometimes just crashes or take 100% CPU, good idea but …..

    Now I am trying to move away to thunderbird. Even this is a mess. Exporting mail hangs on certain folders and I have to copy around the content of this folder to get export working again …..

    KDE Desktop is going down. From my point of view the two main applications that made me move to KDE a long time ago are broken now:
    Kmail and Amarok …. it is such a disappointment.

Leave a Reply