How to restrict mailman list subscriptions to certain domains?

Solution 1:

Mailman uses Python's regular expression engine, which is flexible enough to match everything except a certain domain.

Put something like this in the ban_list for the list: ^(?!.*example\.edu) or: ^(?!.*(example\.edu|example\.com))

If lists are restricted and getting spam subscriptions, you may want to not advertise the list in mailman (make the link available elsewhere). Setting the mailing list subscription policy to "Confirm and Approve" instead of "Approve" so that spammers have to handle a piece of email before the list owner is annoyed can help, too.

Solution 2:

Other answers will not stop an email address like "[email protected]". This will: ^(?!.*[@.]example\.com) (assumes all subdomains of example.com are okay). To apply run:

config_list -i <(echo 'ban_list = [ "^(?!.*[@.]example\.com)", ]' ) listname