On 2022-10-23 16:38, horvath.arpad.szfvar@gmail.com wrote:
Hi,
I've tried to add new members to the mailing list, but I failed even if I tried 3 ways:
- manage.py shell
- invitation letter
- sending a letter to subscribe.
I try to solve it with the Python shell now. Based on this site: https://docs.mailman3.org/projects/mailman/en/latest/build/lib/mailman/model... I tried this one from Debian bash command line, but there is an error message, as you can see at the end. Hi,
we use mailmanclient for that to automatically sync the membership of mailinglists.
import configparser import mailmanclient
mmc = mailmanclient.Client( config[CONFIG_MM_SECTION]['url'], config[CONFIG_MM_SECTION]['user'], config[CONFIG_MM_SECTION]['password'], )
def mailinglist_manage(list_address, members): """ make sure all 'members' are present on the list and not remove everyone else
list_address : mail address of mailing list to manage
addresses : mail addresses that are supposed to be on the list
"""
print("[*] update subscriptions for {}".format(list_address))
ml = mmc.get_list(list_address)
# make sure we dont spam users
ml.settings['send_welcome_message'] = False
ml.settings.save()
addresses = set(members.keys())
ml_members = ml.members
ml_addresses = set((x.address.__str__() for x in ml_members))
for addr in ml_addresses - addresses:
print("unsubscribe {} from {}".format(addr, list_address))
ml.unsubscribe(addr)
for addr in addresses - ml_addresses:
print("subscribe {} to {}".format(addr, list_address))
ml.subscribe(addr, members[addr],
pre_verified=True, pre_confirmed=True,
pre_approved=True)
This should be starting point for your script.
Please be aware that we are using the virtualenv installation type and you seem to use the default debian package so your version of mailmanclient might be different.
Jacob