[Mailman-Users] Unable to set defaults for header_filter_rules

Mark Sapiro mark at msapiro.net
Wed Dec 5 00:44:45 CET 2012


Mikael Jokela wrote:
>
>I would like to set a default value of header_filter_rules for new
>lists. It would be something like this
>
>DEFAULT_HEADER_FILTER_RULES = [('X-Spam-Flag: YES', 3, False)]
>
>The purpose would be to discard all messages that are marked as spam.


header_filter_rules is set to the empty list when a new list is
created. There is no configuration option to do otherwise. To change
this, you could modify the line

        self.header_filter_rules = []

in the definition of the InitVars() method of the MailList() class in
Mailman/MailList.py to read

        self.header_filter_rules = mm_cfg.DEFAULT_HEADER_FILTER_RULES

and then Mailman would get this from a definition in mm_cfg.py or
Defaults.py. Of course, it must then be defined. I.e. a full
implementation would patch the source Defaults.py.in to include

DEFAULT_HEADER_FILTER_RULES = []

and some documentation. This then would add

DEFAULT_HEADER_FILTER_RULES = []

to Defaults.py when Mailman was configured, and then this setting could
be overridden in mm_cfg.py.


>I can't get this kind of default configuration working nor find any
>other way of doing this apart from doing this manually after creating
>the list.


You either need to implement something on the above lines or do it
somewhat manually. You can do it by manually running something like

#!/ban/bash
f = `mktemp`
echo "header_filter_rules = [('X-Spam-Flag: YES', 3, False)]" > $f
/path/to/mailman/bin/config_list -i $f NEW_LIST_NAME
rm $f

after creating NEW_LIST_NAME, or see
<http://www.msapiro.net/scripts/set_attributes>.

If you create lists from the command line, you could make one script to
invoke bin/newlist to create the list followed by the above to
configure it.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list