add / remove / set moderation bit of non-members via mailman shell
I have a situation where I need to add / remove 10-20 non-members to a particular list every week and set the moderation bit to 'accept immediately (bypass other rules).
I do the above via postorius because I couldn't find a way to do this via mailman shell.
Can anyone help me please to achieve the above? I know how to remove all non-members via
/opt/mailman/mm/bin/mailman shell -l list.example.com
for nonmember in m.nonmembers.members: ... nonmember.unsubscribe() ... commit()
I am just having difficulties adding the non-members and setting the moderation bit to 'Accept'
Currently I am using Mailman 3.2.2 (La Villa Strangiato) and Postorius Version 1.2.4 so cant use 'postorius => settings -> message acceptance -> id_accept_these_nonmembers'
-- Regards, Zaheer
On 2/7/24 02:37, Zaheer Abbas wrote:
I do the above via postorius because I couldn't find a way to do this via mailman shell.
Something like
mark@msapiro:~$ mailman shell -l list@example.com
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
The variable 'm' is the list@example.com mailing list
>>> NEW_NONMEMBERS = [('First User', 'user1@example.com'),
... ('Second User', 'user2@example.com'),
... ('Third User', 'user3@example.com'),
... ]
>>> from mailman.app.membership import add_member
>>> from mailman.interfaces.subscriptions import RequestRecord
>>> for display_name, email in NEW_NONMEMBERS:
... record = RequestRecord(email,
... display_name=display_name,
... delivery_mode=None,
... )
... member = add_member(m, record, role=MemberRole.nonmember)
... member.moderation_action = Action.accept
...
>>> commit()
>>>
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
Zaheer Abbas