[Users] Migrating from KMAil-1 (with mbox) to Claws-Mail
Renaud OLGIATI (Ron)
renaud at olgiati-in-paraguay.org
Fri May 24 14:30:55 CEST 2013
With mageia 1 reaching its end-of-life, I suppose there will be others like me who held on as long as they could so as not to face the (perceived) horrors of Kmail-2 and will migrate to Claws Mail.
The following is how I did the migration, in case it can help them.
Thank $DEITY it is over, and I can now look forward to upgrading my OS without too much fear, and finally reach that holy grail of getting rid of KDE now that I have removed the vendor-lock-in of Kmail !
To the people of the KDE list, it is good bye from me, I will now unsubscribe as I will no longer need your kind help.
My thanks to all, on all lists, who have helped me over the years.
Ron Olgiati, on the banks of the Paraguay River.
We have met the enemy, and he is us.
-- Walt Kelly
-- http://www.olgiati-in-paraguay.org --
Migrating from KMAil-1 (with mbox) to Claws-Mail
Having got fed up with KDE as the years went by and KDE became more and more bloatware, I have finally decided to bite the bullet because Mageia-1 has reached its end of life, and upgrading to Mageia-2 (or 3) entails moving to Kmail-2, of which I had heard less-than-shining reports; so the time has come now to migrate to Claws Mail, get rid of KDE and move to a lighter Desktop Environment in the new release of Mageia. This is how I have done it.
First open Kmail, "un-tree" any folder that is inside another folder, and bring them up to the "Local folders" level. Then compact all folders (or deleted mails will re-appear).
Open addressbook, and export as a LDIF file.
Create a temporary directory (~/toto) and use Valentin Koch's mbox2mh script to migrate all your mbox mail folders from /.kde4/share/apps/kmail/mail to mh folders in ~/toto. This is to avoid any unpleasantness if any of your Kmail folders have the same name as a CM folder. Then move all those folders from ~/toto to your CM directory, changing names if needed.
Open CM, right-click on the top item of the folders list "mailmh (MH)" and click "Check for new folders"; wait while _all_ your mails are gone through; then right-click on each folder in turn, and click "Mark all as read" (all your mails were read, no ?).
Go to Tools => Addressbook, then Tools => Import LDIF file to add the content of your Kmail addressbook to the CM addressbook.
If you had but a few filter rules, re-create them with the GUI; if you had a mort of them, see below.
renaud at olgiati-in-paaguay.org
Importing Kmail-1 filtering rules to Claws Mail
the only thing keeping me in KDE was the migration from KMail-1, as I had over 125 filtering rules I did not relish entering one by one using the Claws-Mail GUI.
So I looked into how could I speed up the process by working directly on the config files.
In KMail-1, the filter rules are part of ~/.kde4/share/config/kmailrc where each rule is in a paragraph beginning with [FilterN] with N the ID number of the rule. In Claws-Mail, they are in ~/.claws-mail/matcherrc, where each rule occupies one line.
Since about 95% of my rules were based on whether a given string was present in either the Subject header, the From header or the whole message, and simply moved the message to a given folder, I have decided to concentrate on those, and do with the GUI the few remaining and more complicated rules.
For the rules based on the presence of a string, in KMail-1 each rule has lines for name= (the name of the rule), one or several filedA, fieldB etc lines for Subject, Message, From etc, the same number of contentsA, contentsB etc lines for the strings, an action-args line for the name of the folder, and an action-name=transfer indicating what the rule does; dead simple.
In Claws-Mail, each rule line starts with 'enabled rulename "Name Of The Rule"' indicating the rule is active, and called 'Name Of The Rule', then one or several 'subject matchcase "string1"', 'from matchcase "string2"' or 'message matchcase "string3"' that indicate which header to filter on with what string, those being separated by '|' if any condition is sufficient for the rule, and '&' if all conditions must be fulfilled.
So I started by making a dummy rule file with the gui, which I then edited using Kwrite; it holds the building blocks I will use for cutting and pasting the rules together, with the addition of strings I will cut and paste from kmailrc :
enabled rulename "" subject matchcase "" move "#mh/mailmh/"
enabled rulename "" from matchcase "" move "#mh/mailmh/"
enabled rulename "" message matchcase "" move "#mh/mailmh/"
| subject matchcase ""
| from matchcase ""
| message matchcase ""
Mode d'Emploi :
Start building your rule with one of the three 'enabled rulename....' segments, depending on whether the first condition of your rule is on Subject, From or Message. If your rule is on Message Body, Any Header etc adjust to suit.
Add | subject..., | from.... and | message... segments to match all the FieldA, FieldB, etc in the Kmail rule, to build the skeleton of the rule.
Copy and paste the name, contentsA, B etc. and action-arg strings from kmailrc in their places between the "" in your rule skeleton.
And Presto, your rule is done. If your rule depends on all conditions being fulfilled together, replace all the '|' of the rule with '&'. If you want your rule to be case-sensitive, use 'match' instead of 'matchcase'.
While a rule in KMail-1 is limited to eight conditions, there does not seem to be any such limitation in Claws-Mail, which means that if you were compelled in KMail-1 to split a rule in several rules doing the same action, you can bring them all together in Claws-Mail.
To check for mis-pasted or forgotten strings, search your file for the strings '""' and 'mailmh/"'.
Once you have finished editing matcherrc, you will have to restart Claws-Mail for the new filter rules to be taken into account.
enabled rulename "test1" subject matchcase "Test2" move "#mh/mailmh/trash" mark_as_read
enabled rulename "test2" from matchcase "olgiati" & subject matchcase "test" & subject match "Case Sensitive" & from regexpcase "ABC*"
& headers_part matchcase "headers" & body_part matchcase "body" & message matchcase "whole message" delete
A quick syntax and vocabulary :
enabled | disabled : whether the rule is active or not.
rulename "string" : the identifier of the rule.
[ from | subject | message | body_part | headers_part ] [match | matchcase | regexpcase ] "string" Where to look for the string, and how (case sensitive, insensitive, regular expression) A tilde ~ at the beginning implies a negation.of the condition. | means OR, & means AND and the two should not AFAIK be mixed in a rule.
[move "#mh/mailmh/string" | delete] : move message to the mail folder string, or delete it.
More information about the Users