SDB:Migrating From KMail to Claws Mail

Jump to: navigation, search

Situation

You want to migrate from KMail to Claws Mail on openSUSE 12.1. You use one or more POP3 accounts and have large amounts of mail and address book data you want to transfer from KMail to Claws Mail.

Whereas KMail uses maildir or mbox format to save mails, Claws Mail uses MH format. If you used mbox format in KMail, importing the mails into Claws Mail can be done directly via a Claws Mail plugin. However, if most or all of your mails were saved in maildir format, you have to convert them into MH format first.

Compared to KAddressBook, the Claws Mail address book appears to be rather basic at first sight -- as Claws does not want to be a fully-fledged PIM (Personal Information Management) application. But apart from names and e-mail addresses, the Claws Mail address book can also store and import data like postal addresses, phone numbers, or information about a contact's home page or organization.

Procedure

The sections below describe how to prepare the migration and how to convert and import the mails and addresses into Claws Mail. Additionally, they provide some hands-on information on how to configure Claws Mail with regards to accounts, templates, expiry rules and filtering rules (similar to what you know from and used in KMail).

Preparing the Migration

  1. Export your KAddressBook to LDIF format.
  2. Take notes (or screenshots) of the account configuration in KMail (POP3/SMTP server, ports, authentication settings).
  3. Back up your mails:
    tar -cjvf <my_mail_archive.tar.bz2> ~/.kde4/share/apps/kmail/mail
  4. Install Claws Mail.
  5. Start Claws Mail.
  6. With the first-run wizard, configure the mail folder to use (usually ~/Mail) and create a (first) mail account.
  7. If (some) of your old mails are in mbox format, select Configuration > Plugins > Load (or Get More if you need to download the plugin first) add the following Claws plugin: mailmbox.so
  8. Close Claws Mail.

Converting/Importing the Mails

There are several scripts around with which to convert the mails from maildir format to MH format. The following two worked fine for me:

Maildir2MH script kmail-to-claws-mail script by Shlomi Fish

  1. Save them to ~/bin and make them executable with:
    chmod +x ~/bin/Maildir2MH ~/bin/kmail-to-claws-mail.pl
  2. In ~/bin/kmail-to-claws-mail.pl, adjust the path to your old/new mail directory in $oldroot/$newroot. (The script does not overwrite your old mails, instead it copies the converted mails to the new mail folder).
  3. Execute the kmail-to-claws-mail.pl script:
    ~/bin/kmail-to-claws-mail.pl
  4. Check the contents of your new mail directory for the converted mails. It should show all former mails, each of them stored as a single file (with the file name indicating its number). Depending on your former mailbox structure, the mails may be sorted into subfolders. The inbox folder will also contain 3 hidden files (.claws_cache, .claws_mark, and .mh_sequences) that are not (yet) present in the subfolders.
  5. Start Claws Mail. Initially, it will only show the messages that had been located directly in your old inbox.
  6. To make any subfolders appear in Claws, right-click the topmost entry in the folder list (if you use a POP3 account, usually "Mail (MH)") and select "Search for new folders". Claws will now create the hidden files for the subfolders as well and show all subfolders in the Folder list on the left hand side.
  7. If any of your old mails folders were in mbox format, import them as follows:
    1. From the Claws menu, select File > Import mbox file.
    2. In the dialog that opens, specify the location of your mbox file and the destination folder in Claws Mail.
    3. Click OK to start the import.

Importing Contact Addresses

Compared to KAddressbook, the claws address book appears a bit sparse at first sight. By default, it will only show a person's name and e-mail address. But it also offers support for vCards, JPilot and LDAP servers and for sorting addresses into multiple address book files.

  1. Open the Claws Mail address book with SHIFT+CTRL+A (or by selecting Tools > Address Book in the Claws menu).
  2. Before importing your old addresses, check which attributes are already defined in the Claws address book (and/or define custom ones):
    1. In the address book, select Tools > Edit Custom Attributes to view a list of default attributes.
    2. To add new ones (e.g. for office url, home street, home zip etc.), enter a "New attribute name" and click "Add".
    3. After having added all attributes you need, confirm your changes with OK.
  3. To import your old address, click Tools > Import LDIF File.
  4. In the dialog that opens, enter a name for the address book and specify the path to the LDIF file.
  5. Click "Forward". Now you need to specify which LDIF Field Names to map with which attributes in the Claws address book:
    1. Select an entry from the "LDIF Field Name" list, enter the "Attribute" you want to map to the field name, activate "Select for Import" and click "Modify". The mapping appears in the list.
    2. Repeat the step for all fields you want to import and map to an attribute.
    3. To start the import process, click "Proceed". Claws shows the newly created address book.

Configuring Claws Mail

Claws Mail allows you to configure multiple accounts (for IMAP/POP3) and multiple MH mailboxes. It is possible to use the same mailbox for multiple accounts.

Accounts and MH Mailboxes

  • To add accounts in Claws: Select Configuration > Edit Accounts.
  • To add another MH mailbox: Select File > Add Mailbox.
  • For each account, define which folders to use for incoming mails (inbox), sent mails (sent), mails to delete (trash), draft mails (drafts) and queued mails (queue). However, the configuration options for those are not at the same place:
    • The inbox is configured via Account Preferences > Receive > Default Inbox.
    • All other folders can be configured with Account Preferences > Advanced > Put sent|queued|draft|deleted messages in...
    • If you want to use the same MH mailbox for several accounts, configure the same folders for multiple accounts.

Templates

Coming from KMail, the Claws templates concept may be a bit confusing at first, because templates can be defined in various places, depending on how you want to use them. However, the concept is powerful, once you have figured out the best setup for your needs:

  • Generic templates can be defined via Configuration > Templates. When composing or answering/forwarding a mail, you can switch between those templates by selecting Tools > Template within the Compose Message window.
  • Templates for a specific account can bed defined via Account Preferences > Templates.
  • Templates for specific folders: Right-click the respective folder and select Properties > Templates. Those templates can be passed on to subfolders.

Automatically Expire Old Mails

To automatically remove old mails from (sub)folders (like in KMail), use processing rules in Claws Mail:

  1. Right-click the (sub)folder and select "Processing". In the dialog that opens:
    1. Enter a name for the processing rule, for example:
      expiry
    2. Define a condition, for example:
      age_greater 30
    3. Define the action to execute if that condition is true, for example:
      delete
  2. Click Add to add the processing rule.
Claws: Example Processing Rule for Expiry

You can also define similar actions in the filtering settings, but there, you cannot assign them to a specific mail (sub)folder.

Filtering Mails

  1. To define filtering rules for mails in Claws Mail, select Configuration > Filtering.
  2. In the dialog that opens:
    1. Enter a name for the filtering rule.
    2. Select to which account the filter should apply.
    3. Define a condition.
    4. Define the action to execute if that condition is true.
    5. Click Add to add the new filtering rule.
Claws: Example Filtering Rule

See also

Related articles

Claws Documentation & FAQs