Thunderbird – Migrating from Kmail to Thunderbird

kmailmigrationthunderbird

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 ?

Best Answer

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
~/.local/share/0/local-mail
~/.local/share/1/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.