[Users] Newbee questions
Renaud (Ron) Olgiati
renaud at olgiati-in-paraguay.org
Wed May 22 23:32:35 CEST 2013
On Wednesday 22 May 2013 16:21 my mailbox was graced by a message from Brad
Rogers who wrote among much precious advice):
> I'm unaware of any method of importing KMail's filter rules into CM;
I rolled my own, which is not automated tool, but goes much faster than using
the CM filtring rules GUI, see below.
I have activated Filter when receiving in the Account Preferences, but it does
not filter; does it have to be activated somewhere else ?
Cheers,
Ron.
--
Eat drink and be merry,
for tomorrow we may diet.
-- http://www.olgiati-in-paraguay.org --
Migrating mail filtering rules from KMAil to Claws-Mail
Getting fed up with KDE as the years go by and KDE becomes more and more
bloatware, I finally decided to bite the bullet, get rid of KDE and move to a
lighter Desktop Environment; the only thing keeping me in KDE was KMail, with
over 125 filtering rules I did not relish entering one by one using the Claws-
MailGUI.
So I looked into how could I speed up the process by working directly on the
config files.
In KMail, 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
occupys 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 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 :
===================================================
[preglobal]
[postglobal]
[filtering]
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 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 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
mailing list