HowTo: Rules

General discussion about PopMan.

Moderator: Christian

Post Reply
User avatar
Christian
Site Admin
Posts: 387
Joined: 11 Jan 2004, 13:04
Location: Magdeburg, Germany
Contact:

HowTo: Rules

Post by Christian »

This HowTo describes how to set up the rules file.

The rules file (Menu: Tools > Rules...) can have as many rules as you want. Rules are separarted by a blank line.

A rule has a very simple structure as you can see in the following example:

Subject contains "Spam" -> MarkForDelete

The first part describes where the rule is searching. It can be the name of any header entry, e.g. Subject, From, To, CC, ... or it's one of the following values:

Mail - The raw source of the entire mail.
Header - The raw header of the mail source.
Message - The extracted message body text shown in the preview pane and message window.

The second part defines how to search. Possible values:

contains - The text must be found anywhere in the where part.
equals - The text must be identical to the where part.
begins with - The text must be found at the beginning of the where part.
ends with - The text must be found at the end of the where part.

The third part defines what to search for. It can be a simple string or a set of strings:

Message contains "str1" -> MarkForDelete
Message contains any of {"str1", "str2", "str3"} -> MarkForDelete
Message contains all of {"str1", "str2", "str3"} -> MarkForDelete
Message contains none of {"str1", "str2", "str3"} -> MarkForDelete


The last part describes the actions that have to be taken:

Read - Mark message as read.
NotNew - Message is not considered "new" (no notification).
MarkForDelete - The message is marked for delete.
Open("file") - Open the specified file, e.g. a program or document, if message is new.
Open("file", "params") - Open the specified file with the given command line parameters, if message is new.
PlaySound("filename.wav") - Play the specified sound file, if the message is new. A certain sound file will only be played once per check.
PlaySingleSound("filename.wav") - Play the specified sound file, if the message is new and no other sound has been played during the current check.
Delete - Delete message from server. Use with care!

Note, that you can assign several actions to one rule:

Mail contains "Spam" -> Read, NotNew, MarkForDelete

You can logically combine several rules with And and Or:

Subject contains "PopMan" And From contains "Christian" -> PlaySound(..)

You can also negate a rule with not:

From not contains "Christian" -> NotNew

When you have finished the modification of the rule file, save it and PopMan will reload it on the next email check.


New features since PopMan 1.3 Beta 14:

- Test for emptyness

Subject is empty -> MarkForDelete

- Search for words instead of arbitrary strings with single quotes, e.g.

Message contains 'Huebner' -> ... will not apply if the message contains just the string chuebner@mail.com

- Search for regular expressions by prepending "regex:" to a string, e.g.

Message contains regex:"[Pp]+.?[Ii1]+.?[Ll1]+.?[lL1]+.?[sS\$]" -> ...

- Add attributes to a rule to specify the name or the relevant accounts:

[Name="Spam", Account="MyAccountName"]
Subject contains "bad word" -> ...


[Name="Spam", Account={"Account1", "Account2", "Account3"}]
Subject contains "bad word" -> ...


- Define strings and lists of strings that can be referenced by name, e.g.:

Message contains any of BADWORDS -> MarkForDelete, NotNew, Read

define list BADWORDS = {
"BadWord1",
"BadWord2",
Pills_RegEx }

define string Pills_RegEx = regex:"[Pp]+.?[Ii1]+.?[Ll1]+.?[lL1]+.?[sS\$]"


- Specify several "where parts" for one condition:

Subject or Message or From contains any of BADWORDS -> ...
Subject and Message and From contains none of GOODWORDS -> ...
Subject+Message+From contains any of BADWORDS -> ...

Think of the + to join (concatenate) strings, although it may be evaluated like OR or AND for efficiency, e.g.:
Subject+Message contains any of is evaluated like Subject or Message contains any of
Subject+Message contains none of is evaluated like Subject and Message contains none of
Subject+Message contains all of must be evaluated using string concatenation because there is no other logical equivalent

So you see it is simpler to just use + and not to bother with all the confusing ANDs and ORs! ;)

When editing the rules file it is helpful to have some kind of syntax highlighting, therefore I've created a user defined syntax file for the famousNotepad++ editor.
Last edited by Christian on 16 Oct 2007, 14:43, edited 3 times in total.
Christian Hübner
Tommy
Posts: 66
Joined: 16 Oct 2005, 07:12

Post by Tommy »

hi Christian.

how do i create a rule to delete mail which contains a defined spam word either in the title or the message?
User avatar
Christian
Site Admin
Posts: 387
Joined: 11 Jan 2004, 13:04
Location: Magdeburg, Germany
Contact:

Post by Christian »

You can use this rule:

Subject contains "YourSpamWord" OR
Message contains "YourSpamWord"
-> Read, NotNew, MarkForDelete


If you really want to delete immediatelly, use Delete after the arrow.
Christian Hübner
Tommy
Posts: 66
Joined: 16 Oct 2005, 07:12

Post by Tommy »

ok, but i'd like to write the SpamWord only one time.
with your rule i have to digit it twice.

is it possible ot have a rule like this:

Subject OR Message contains "YourSpamWord" -> MarkForDeleteù
User avatar
Christian
Site Admin
Posts: 387
Joined: 11 Jan 2004, 13:04
Location: Magdeburg, Germany
Contact:

Post by Christian »

No, this is not possible. You will have to repeat the word...
Christian Hübner
Tommy
Posts: 66
Joined: 16 Oct 2005, 07:12

Post by Tommy »

:(
User avatar
tengvilla
Posts: 72
Joined: 11 Jun 2004, 19:45
Location: san francisco, california [usa]

HowTo: Rules

Post by tengvilla »

Hi Christian,

Got question? How can I use or add the special character one quote " in rules?

i.e. in your example
Subject contains "YourSpamWord" OR Message contains "YourSpamWord"

my example
Subject contains "YourSp"amWord" OR Message contains "YourSp"amWord"

Is this possible? Or special character one quote " can not be overridden.
:)
User avatar
Christian
Site Admin
Posts: 387
Joined: 11 Jan 2004, 13:04
Location: Magdeburg, Germany
Contact:

Post by Christian »

You have to mask the " character by preceding a ~ character, like this:

Subject contains "YourSp~"amWord" OR Message contains "YourSp~"amWord"

This also implies that you have to write ~~ if you really mean one ~ character.
Christian Hübner
User avatar
tengvilla
Posts: 72
Joined: 11 Jun 2004, 19:45
Location: san francisco, california [usa]

HowTo: Rules

Post by tengvilla »

Thanks Christian!!! Learnt something new again.

Question:

Except for tilde ~
AND
double quote "

what other special characters used by rules need to be mask?
User avatar
Christian
Site Admin
Posts: 387
Joined: 11 Jan 2004, 13:04
Location: Magdeburg, Germany
Contact:

Post by Christian »

I think that all.
Christian Hübner
Post Reply