SDB:Migrating From KMail to Claws Mail
tagline: From openSUSE
- 1 Situation
- 2 Procedure
- 3 See also
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.
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
- Export your KAddressBook to LDIF format.
- Take notes (or screenshots) of the account configuration in KMail (POP3/SMTP server, ports, authentication settings).
- Back up your mails:
tar -cjvf <my_mail_archive.tar.bz2> ~/.kde4/share/apps/kmail/mail
- Install Claws Mail.
- Start Claws Mail.
- With the first-run wizard, configure the mail folder to use (usually ~/Mail) and create a (first) mail account.
- 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
- 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:
- Save them to ~/bin and make them executable with:
chmod +x ~/bin/Maildir2MH ~/bin/kmail-to-claws-mail.pl
- 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).
- Execute the kmail-to-claws-mail.pl script:
- 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.
- Start Claws Mail. Initially, it will only show the messages that had been located directly in your old inbox.
- 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.
- If any of your old mails folders were in mbox format, import them as follows:
- From the Claws menu, select File > Import mbox file.
- In the dialog that opens, specify the location of your mbox file and the destination folder in Claws Mail.
- 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.
- Open the Claws Mail address book with SHIFT+CTRL+A (or by selecting Tools > Address Book in the Claws menu).
- Before importing your old addresses, check which attributes are already defined in the Claws address book (and/or define custom ones):
- In the address book, select Tools > Edit Custom Attributes to view a list of default attributes.
- To add new ones (e.g. for office url, home street, home zip etc.), enter a "New attribute name" and click "Add".
- After having added all attributes you need, confirm your changes with OK.
- To import your old address, click Tools > Import LDIF File.
- In the dialog that opens, enter a name for the address book and specify the path to the LDIF file.
- Click "Forward". Now you need to specify which LDIF Field Names to map with which attributes in the Claws address book:
- 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.
- Repeat the step for all fields you want to import and map to an attribute.
- 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.
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:
- Right-click the (sub)folder and select "Processing". In the dialog that opens:
- Enter a name for the processing rule, for example:
- Define a condition, for example:
- Define the action to execute if that condition is true, for example:
- Enter a name for the processing rule, for example:
- Click Add to add the processing rule.
You can also define similar actions in the filtering settings, but there, you cannot assign them to a specific mail (sub)folder.
- To define filtering rules for mails in Claws Mail, select Configuration > Filtering.
- In the dialog that opens:
- Enter a name for the filtering rule.
- Select to which account the filter should apply.
- Define a condition.
- Define the action to execute if that condition is true.
- Click Add to add the new filtering rule.