Let’s say you have a local copy of a mail folder you want to browse with Kmail . This folder is normally found on a dedicated mail server and you access it through the IMAP protocol. I was in this situation some days ago and I will tell you how I’ve done it.

Instinctively, I assumed that my folder was of the Maildir format , and Kmail local mails too. So I tried to copy my ~/Maildir folder from the mail server to my local machine ( ~/.kde/share/apps/kmail/mail/ ). And that was the result in Kmail:

kmail-no-sub-folders.png

It looks good but it’s not: there is no sub-folders!

After some googling, I found what was wrong: my ~/Maildir folder is not a Maildir, but a Maildir++ folder. This kind of folder is handle by popular IMAP MTA like qmail , Dovecot and courier-imap (which was used on the mail server where my ~/Maildir come from). There is some advantages of using the “ ++ ” flavor of Maildir over the classic one, like quotas and sub-folders. Unfortunately Kmail is not able to read the Maildir++ folder structure  .

To fix this, I’ve created a tiny python script to migrate a Maildir++ folder to Kmail  .

How-to use it? Simply:

  1. Download it to your disk,

  2. Edit it and change the MAILDIR_SOURCE and KMAILDIR_DEST variables to match your local configuration,

  3. Give it execution privileges,

  4. Run it!

I advise you to try it first in a safe environment (like under a temporary user account). And don’t forget to backup everything before playing with it: because this script work for me doesn’t mean that it will work for you! ;)