Clean start after a failed migration

In case migration from KMail 1 to KMail 2 fails or you have weird problems after it, you can try to do a clean import of your data, instead of migrating the existing settings. Be warned, this needs more manual setup, so do only if you are confident of setting up your KMail accounts again; it can generate a large amount of network traffic for IMAP resources.

  1. Stop Akonadi and related applications

    quit KMail/Kontact/KOrganizer, and issue this command:

    akonadictl stop

    Make sure no Akonadi or MySQL process is running:

    ps ux | grep mysql

    ps ux | grep akonadi

    They should not show anything else but the grep process itself.

  2. Remove old Akonadi database and config

    Delete the following folders

    • ~/.local/share/akonadi

    • ~/.config/akonadi

    Delete also the files starting with akonadi from ~/.kde4/share/config

  3. Restart Akonadi server

    akonadictl start

  4. Add back the accounts

    Now it is time to add your account back. You can use KMail (Kontact) for it, or you can use the akonadiconsole tool.

    In KMail: SettingsConfigure KMailAccounts and use Add.

    If you use IMAP, add a new IMAP E-Mail server. If you want disconnected mode (so you can read the mails offline), enable it on the Advanced tab. Be sure to check that you are subscribed to all your important folders.

    You might already see a Local folder resource. This points to a local maildir folder. You can either modify this to point to your existing maildir folders or you can add a new resource for local mails.

    When adding a maildir resource you can choose between KMail Mail Folder or Maildir. Unless you have a mixed folder containing both maildir folders and mbox files, you should choose Maildir. For independent mbox files, like the one in the /var/spool/mail, you can set up a new MBox folder.

    Add the POP3 accounts as well. If you have multiple Local Folders set up, on the Advanced tab, choose the destination folder where the newly downloaded mails are put.

    For all accounts, configure the mail check interval. For Local folders disable interval checking and also disable Include in manual mail check in the Retrieval options.

    Add the sending (SMTP) accounts.

  5. Fix your filters, identities and favorite folders

    If you have client side filtering (common with POP3 mails), go to SettingsConfigure Filters and fix the destination folder for the filters, they most probably are wrong. Otherwise mails will end up in folders you don't expect.

    Spam filter (at least in version 4.7.3 and earlier) does not work as expected in that the rule that the wizard creates does not send spam to the folder you have defined.

    The workaround for this is to change the spam and spam unsure (if the spam filter you use supports that) from looking at Status-fields in the header X-Spam-Status to look Anywhere in headers for X-your spam filter-Classification: SPAM or unsure. Look at the filters the wizard creates and copy the contains part. Example for Spambayes: X-Spambayes-Classification: spam and X-Spambayes-Classification: unsure.

    You also need to verify the identity settings and set the sent-mail, drafts and templates folders to point to the right folders. To do that go to SettingsConfigure KMailIdentities, modify the identity, go to the Advanced tab and modify the above mentioned folder settings.

    Check also that your Favorite Folders are the ones you have chosen before.

  6. Initiate a mail check

    Start a mail check for your accounts. It is suggested doing it per account.

    First check for IMAP, if you have it.

    Next check (import) your local mails. One solution is to do a full check in one go FileCheck Mail In and select the local account; the other is to click one by one on the folders, that should initiate the check for that folder (alternatively right click on the folder name and select Update Folder).

    The initial import might be slow and could use a lot of memory, especially if you have folders with a large amount of mail. In that case per-folder check is preferred. If the check (complete or for one folder) is finished and the memory usage is still high, you could restart the Akonadi server — as seen above — or just the maildir agent, if you use akonadiconsole. Do not worry, this high memory usage is only for initial import.

    Initiate a check mail for POP3 resources.

Hopefully after these steps, you will have a much nicer KMail experience.