[Mailman-Users] Additional questions about ban_list

Mark Sapiro mark at msapiro.net
Wed Oct 7 02:43:58 CEST 2015

On 10/06/2015 08:07 AM, Chris Nulk wrote:
> 1. The ban_list attribute is to help prevent unwanted people from
> subscribing to a list, however, I want to restrict who can subscribe to
> the list and ban anyone else.  I have the regex for who I want to allow
> to subscribe but there isn't an allow_list attribute.  Is there an easy
> way of allowing a regex to control who is able to subscribe?  Or, is
> there a way to easily invert the regex logic and use it in ban_list?  As
> an example (not the real regex), say I want to only allow @gmail.com to
> subscribe to the list but no one else.

As Aditya Jain replied, you can use Python RE negative lookahead
assertions to create regexps with "doesn't match" conditions. See

Although the posted regexp modified for gmail


will not match and hence allow, addresses like user at subdomain.gmail.com.
To allow only '@gmail.com' addresses, e.g. to ban all non-'@gmail.com'
addresses, use


Often, if you have the regexp to allow, the regexp to ban may be as
simple as


> 2. An additional requirement is to restrict a subgroup of the addresses
> from subscribing.  In short, I want to allow all @gmail.com addresses to
> subscribe except for a known subgroup.  Now the known subgroup is in a
> Mailman list.  So, can I use a Mailman list in the ban_list attribute
> similar to using a list in *_these_members attributes?  Or, would I have
> to modify the code to allow using a Mailman list in the ban_list attribute?

Allowing @list_name in ban_list is a simple code modification if you
don't care if various 'error' log messages such as list references
itself or references non-existent list refer to
'subscribe_auto_approval' even if the error is in ban_list.

The change would be in this code in Mailman/Mail.List.py

    def GetBannedPattern(self, email):
        """Returns matched entry in ban_list if email matches.
        Otherwise returns None.
        return self.GetPattern(email, self.ban_list)

change the last line to

        return self.GetPattern(email, self.ban_list, at_list=True)

Or, if you've installed the GLOBAL_BAN_LIST mod, make the change in each
of the two lines in

        return (self.GetPattern(email, self.ban_list) or
                self.GetPattern(email, mm_cfg.GLOBAL_BAN_LIST)

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