Switching from KMail to Thunderbird

posted on Nov 20, 2011

KMail needs to go...

I have been very conservative with my email software. One of the reasons is that I have a massive mail folder and keep eons of email (ie 1994 onwards). There are large numbers of folders and some folders contain tens of thousands of messages... In this scenario you don't move to new software very frequently. I started off with MH (command line on Unix), then briefly with Eudora (Windows 3.1), but stabilized to Pegasus Mail while I used Windows. When I took the plunge and got rid of Windows entirely, in 2003, I started using KMail, the KDE mail client.

KMail was faithful for a long time but now that the KDE folks are messing around with Akonadi et al. I've started having lots of problems with KMail. I finally decided I need to move on, and after a bit of searching on the web (mainly the Slackware forum on LinuxAnswers), I finally decided to go with Mozilla Thunderbird.

Requirements

My configuration requirements are the following:

  • I run Slackware on all my computers (most are on 13.37, some still on 13.1)
  • I connect to two different work accounts (ie two entirely different sets of SMTP/IMAP servers)
  • I like to copy everything to my local store, because I need to access all my email when I am offline. (I don't trust the cloud that much...)
  • I like to leave a few months of email on the IMAP server so that I can access them through webmail if needed
  • I synchronize my home folder between several computers and portable drives; essentially there are 4 live copies (can all be used at any time) and a couple of portable drives. Everything is synchronized using unison.
  • I want to be able to have the same Thunderbird local folders on various (synced) computers but each one should have their own profiles (because of font sizes, etc.)
  • I don't really want to copy around (sync) the cached IMAP messages (because they are on IMAP server anyway and it is a bit of volume: approximately 5000 messages)

Setting up Mozilla Thunderbird

The first thing I did was setup thunderbird on one of the computers. Fortunately thunderbird is already part of Slackware so no need to install any packages. The other steps were:

  1. I configure my IMAP and SMTP work accounts, then close Thunderbird.
  2. I copied the contents of the local mail store to ~/Mail using the information on mozillazine (essentially move the folder "Mail/Local Folders" to ~/Mail and change Thunderbird to recognize this)
  3. At this stage I have the basic configuration, where the profile is under ~/.thunderbird (which is not synced) and the local mail is in ~/Mail (which is synced).
  4. I repeat the configuration of Thunderbird on the other computers and there also change the Local Folders to point to ~/Mail (beware that on those there is nothing to copy, just change the location)

Migrating the folders from KMail into Thunderbird local folders

I use the python script posted by Jakob Schiøtz to import the KMail folders into the new Thunderbird local folders. I piped the output of the script to a text file and then carefully went over this to make sure that there were no errors... After running the script I started Thunderbird to check that my gigantic email tree is all there. At this stage it is useful to click on every folder, so that Thunderbird can create an index for each folder.

There is also a different script to do this job but it did not work well for me.

Making IMAP work like POP3

I like to use the IMAP server only as a temporary store of my recent messages, a bit like I used to work with a POP3 server. Essentially I want all new messages to be copied to the local folder. They should show as new in the local inbox and as read in the IMAP server. However I want to copy all new messages, not just the unread ones (because I may have read the message over webmail, I still want it copied to local). This was a lot harder to configure on Thunderbird than I ever expected (not that it was too easy with KMail either...). This is how it works:

  • Create a filter on the IMAP inbox to copy messages to local inbox. Name it "IMAP to Local" and make it run when checking email (this is important). Search criterion is "Tags doesn't contain Local", the actions are "Tag Message Local" and "Copy Message To Inbox on Local Folders". This filter will copy messages to the local inbox as they arrive, but leaves them marked as unread on both inboxes (IMAP and local)
  • Create a filter on the IMAP inbox to copy messages to local inbox. Name it "Mark Copied as Read" and make it run when checking email (after classification) (this is important). Search criterion is "Tags contains Local" AND "Status isn't Read", the action is "Mark as Read". This filter will then mark the messages that have already been copied to local as read, but only in the IMAP inbox (ie they stay marked unread in the local inbox)