TISNOP mail filter 2002 Dec 01
Version 0.0.1 - never tested in real life environment!
- how do I discard a mail (/dev/null)?
the mail walks trough tisnop, what happens if nothing
comes out at the other end?
- multipart support not yet implemented.
- what shall happen when a mail with wrong format arrives?
e.g. a mulipart without closing tag? /dev/null?
- more actions needed. Currently only header rewrite.
The ideas with tisnop are:
- filtering with python regular expressions
- easy configuration in python syntax
- no cryptic letters to learn. (":0 Bf:" or ":0 :Bf"? :-) )
tisnop is two files:
- tisnop : python module
- tisnop01.py : a mail filter
The configuration is rule based, whereas every rule
has a name, a list of conditions, and a list of actions.
c_texthtml = \
"pure html mail", # a name
tisnop.HEADER, # no tisnop.BODY at this time,,,
"Content-type", # field in header
re.compile("text/html") ) # a regexp
a_mark_spam = \
"MARK_SPAM", tisnop.HEADER, "Subject", "SPAM: %S" )
tisnop1.addRule( "Only HTML Content" , [c_texthtml], [a_mark_spam] )
- conditions and actions have four parameters
- conditions use python regular expressions
- everything has a name
- You can use placeholders (%S %T %F %C %D)
- there's no cryptic syntax to learn
- implict "AND" operator in conditions list
Currently tisnop supports only HEADER based conditions and actions.
tisnop does not support things like "COND1 AND (COND2 OR COND3)".
You have to write two rules instead:
add.Rule( "rule_1a", [COND1,COND2], [ACTION1] )
add.Rule( "rule_1b", [COND1,COND3], [ACTION1] )
And there's no NOT operator!
To test that something is not in a field, write an appropiate regexp:
c_nomagic = re.compile("^(?!magic)") # no ^magic (in Subject).
This is easier to implement and easier to learn.