I like the kmail interface, but I've had problems with it for years and in the last few days it has become unusable: it keeps locking up or crashing and there's no solution on the 'net. I won't go into details as I'm sick of it.

I tried reseting its settings (https://forum.kde.org/viewtopic.php?f=20&t=97754) to no avail. I want to move Thunderbird, but I haven't found a way to import the messages/accounts/filters: In Thunderbid the [Tools][Import] then [Next] brings me to an empty window with only [Cancel]. From kmail I managed to export everything to a zip export file, but I don't know what to do with it.

I searched for import add-ons for thunderbird without success. I've read some messages that say to move the /cur/ directories manually but that's only for the messages, right ? Any advice ?

  • 1
    No you need to export to a MBOX file. TBird can load mboxes with no problem.
    – Rinzwind
    Jan 19 '17 at 20:57
  • Strange, I have an opposite experience. KMail is working better and better. Have no complaints at all for 16.12.1 Jan 19 '17 at 21:58

I finally found a solution. Like Timothy Truckle wrote, I used the export/import plugin, BUT before that, I had to rename the mail files, otherwise the import would only show empty directories.

First, find where kmail stores your messages (there may be more than one place if you have several accounts):

$ ls -1d ~/.local/share/local-mail ~/.local/share/*/local-mail

Then in EACH of those directories, do ALL of the following:

# This performs a backup
zip -r ~/mail.backup.zip ~/.local/share/local-mail
cd ~/.local/share/local-mail
# This renames the files so that the import will identify them properly
find -type f -exec mv -v '{}' '{}.eml' \;

Now you could stop here and go import the directories in Thunderbird, but you will end up with a lot of empty directories and misnamed directories, such as .Friends.directory or .Family/cur, so a little scripting can clean things up first.

# Remove empty directories
find -type d -exec rmdir -v '{}' \;
# Move the files up from cur/, tmp/ and new/
find -type d -name cur -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -name tmp -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -name new -exec bash -c 'for dir; do mv -v "$dir"/* "$(dirname "$dir")/"; done' bash {} +
find -type d -exec rmdir -v '{}' \;
find -type d -iregex "\..*\.directory"
# Now move ../.something.directory into ../something (which may not exist)
find -depth -type d -iregex "\..*\.directory" -exec bash -c 'for dir; do A=$(echo $dir | sed -e "s#\(.*\)\.\([^/]*\).directory#\1\2#"); mv -v "$dir"/* "$A/" ; done' bash {} +
# if there are still .something.directory, just rename them manually to 'something' (this line won't do it automagically):
find -type d -iregex "\..*\.directory"

Finally, in Thunderbird, create a directory IMPORT under Local Folders, select it (don't forget as right-click is not enough!), right-click on it, [ImportExportTools], [Import all messages from Directory, also its subdirectories], and let it work for a while.

I could write a script to do all of the above, but now that I've finally managed to move my mail, I'm just fed up with it.


Thunderbird has an export/import plugin where you can import mail message fom KMail folder structure. https://addons.mozilla.org/de/thunderbird/addon/importexporttools/

Unfortunately you cannot import the folder structure and the mail messages at the same time (at lease I could not).

I accidentally imported the folder structure but without any mails, so is deleted it. Unfortunately I could not reproduce that so that I had to recreate my folder structure in TB from scratch.

Then you have to import the mail messages for each folder separately. The menu of the TB import/export plugin does have "with subfolders" entries but they did not work for me.

  • And where is this plugin / what is it named ? The integrated [Import] doesn't do a thing as I stated earlier.
    – dargaud
    Jan 20 '17 at 13:00
  • 1
  • Same here, it imported only empty structure. That thing is a nightmare, I'm not going to import manually hundreds of directories...
    – dargaud
    Jan 20 '17 at 21:55
  • If still interested, see my solution below.
    – dargaud
    Feb 11 '17 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.