Regular expressions are used within the Python programming language (which is what Mailman is written in) and other programming languages to specify rules for matching strings of text. In other words, you can use regular expressions to match text in incoming email messages. The settings in which you use the regular expressions will tell Mailman what to do with messages that have matching text.
The most common use of regular expressions in Mailman is to specify entire domains that can and cannot post messages to your list. For example, to allow all addresses in the ucsd.edu domain, even those addresses that are not subscribed, to post messages without moderation to your list, go to Privacy Options and then the Sender filters sub-category and enter the following regular expression in the accept_these_nonmembers setting:
The ^ specifies that the string is a regular expression. The .* specifies that any text that comes before the “ucsd.edu” part of the email address of the sender is acceptable. For example, firstname.lastname@example.org, email@example.com, and firstname.lastname@example.org will all match the regular expression. The \ specifies that the subsequent period is part of the text of the string you want to match and not a special character that can be used in regular expressions. The $ specifies that it is the end of the string.
Please be aware that spammers often forge the headers of spam email. If the forged From header is set to an email address ending in ucsd.edu, that message will be able to get through to your list. If you are concerned about spam on your list, see how to reduce spam on your mailing list.
To ban an entire domain from being able to post to your list and have Mailman automatically discard all messages from that domain, enter the following regular expression in the discard_these_nonmembers setting on the Privacy Options category → Sender filters subsection of the admin pages:
where “domain” is the domain you want to block.
If you want to ban all non-UCSD email addresses from subscribing to your list, enter the following regular expression in the ban_list setting on the Privacy Options category → Subscription Rules subsection of the admin pages:
As you can see, this regular expression is a little more complex than the preceding ones. This regular expression is known as a negative lookahead and is telling Mailman to match subscribing email addresses that don’t end in “ucsd.edu” and to ban those matching email addresses.
The following settings in Mailman will accept regular expressions:
If you still have questions or need additional assistance, please submit a ticket or call the ITS Service Desk at (858) 246-4357