how to administrate mailman3 in CLI ?
Hello,
I have installed mailman3 and i want to administrate it with rest api, i ve read https://mailman-cli.readthedocs.io/en/latest/src/mailmanclient/cli/docs/usin... and https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/p... and https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/commands/do...
i tryied with mailman command, but it don't do some actions (eg. delete held messages...). i tryied mailman shell...
i tryied with curl to manage it, i can see if there is a pending message with :
curl --user restadmin:restpass http://localhost:8001/3.1/lists/ml@domain.tld/held/count|| python3 -m json.tool|
but how to delete all held messages ? is it possible in one time ? And how to select a specific message to discard /accept / defer ?
do i have to use a POST ?
Regards,
PatG
Hi
testeur via Mailman-users writes:
I have installed mailman3 and i want to administrate it with rest api,
Do you really mean REST API, or do you mean CLI?
i tryied with curl to manage it, i can see if there is a pending message with :
curl --user restadmin:restpass http://localhost:8001/3.1/lists/ml@domain.tld/held/count|| python3 -m json.tool|
This is a lot easier using "mailman shell" if you want to use CLI, or a Python program using mailmanclient if you really want to use the REST API for some reason.
This is explained here: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/model/docs/... but it's likely to be pretty rough going for you because it's really oriented to programmers studying to be Mailman developers, not for admins.
but� how to delete all held messages ? is it possible in one time ?
No, you need to fetch the list and then loop over the messages.
And how to select a specific message to discard /accept / defer ?
do i have to use a POST ?
This is all explained here: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/p...
Steve
Hi,
I try to find documentation and examples to manage mailman3 with "mailman shell". By example, when i tryied just to define global configuration for all users, like in this example ( https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/thread/K... ), but it changes nothing :
|# mailman shell -l testlist@domain.tld | ||>>> from mailman.interfaces.action import Action >>> for mbr in m.members.members: mbr.moderation_action = Action.defer |||commit()|
|||>>> from mailman.interfaces.action import Action |||||||>>> english = getUtility(ILanguageManager).get('en')| >>> for mbr in m.members.members: || mbr.preferences.acknowledge_posts = False mbr.preferences.delivery_mode = DeliveryMode.regular mbr.preferences.delivery_status = DeliveryStatus.enabled mbr.preferences.hide_address = False mbr.preferences.preferred_language = english mbr.preferences.receive_list_copy = False mbr.preferences.receive_own_postings = True|commit()||
Before the shell command, the web interface was with an other language (i tested with italian one) and other options preferences, but after the shell command, after a web interface refresh, it doesn't change.
am i wrong somewhere ?
Regards,
On 16/09/2023 23:05, Stephen J. Turnbull wrote:
Hi
testeur via Mailman-users writes:
I have installed mailman3 and i want to administrate it with rest api,
Do you really mean REST API, or do you mean CLI?
i tryied with curl to manage it, i can see if there is a pending message with :
curl --user restadmin:restpass http://localhost:8001/3.1/lists/ml@domain.tld/held/count|| python3 -m json.tool|
This is a lot easier using "mailman shell" if you want to use CLI, or a Python program using mailmanclient if you really want to use the REST API for some reason.
This is explained here: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/model/docs/... but it's likely to be pretty rough going for you because it's really oriented to programmers studying to be Mailman developers, not for admins.
but how to delete all held messages ? is it possible in one time ?
No, you need to fetch the list and then loop over the messages.
And how to select a specific message to discard /accept / defer ?
do i have to use a POST ?
This is all explained here: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/p...
Steve
Mailman-users mailing list --mailman-users@mailman3.org To unsubscribe send an email tomailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/ Archived at:https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/...
This message sent totesteur@starinux.org
On 9/23/23 07:40, testeur via Mailman-users wrote:
|# mailman shell -l testlist@domain.tld |
It looks like you are running mailman shell
as root
. You should
always run mailman commands including starting mailman as the Mailman
user, never as root. Running thing as root can create things that later
can't be read by the mailman user.
||>>> from mailman.interfaces.action import Action >>> for mbr in m.members.members: mbr.moderation_action = Action.defer |||commit()|
|||>>> from mailman.interfaces.action import Action |||||||>>> english = getUtility(ILanguageManager).get('en')| >>> for mbr in m.members.members: || mbr.preferences.acknowledge_posts = False mbr.preferences.delivery_mode = DeliveryMode.regular mbr.preferences.delivery_status = DeliveryStatus.enabled mbr.preferences.hide_address = False mbr.preferences.preferred_language = english mbr.preferences.receive_list_copy = False mbr.preferences.receive_own_postings = True|commit()||
I'm not sure what the above actually says. The interaction should look like
>>> from mailman.interfaces.action import Action
>>> english = getUtility(ILanguageManager).get('en')
>>> for mbr in m.members.members:
... mbr.preferences.acknowledge_posts = False
... mbr.preferences.delivery_mode = DeliveryMode.regular
... mbr.preferences.delivery_status = DeliveryStatus.enabled
... mbr.preferences.hide_address = False
... mbr.preferences.preferred_language = english
... mbr.preferences.receive_list_copy = False
... mbr.preferences.receive_own_postings = True
...
>>> commit()
Actually, importing Action is not necessary as it is among the things
defined by default in mailman shell
in interactive mode.
Before the shell command, the web interface was with an other language (i tested with italian one) and other options preferences, but after the shell command, after a web interface refresh, it doesn't change.
The above shell interaction sets the preferred_language for all list members to english. This has nothing to do with the language for the web UI. This is set by Django. See <https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#how-django-di...>.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Sorry. I didn't see in the good place. when i see parameters here : https://URL/mailman3/postorius/accounts/per-subscription-preferences/ the options or the specific language chosen (not for the ui) for the list is finally changing when i use the code used before...
i should use shell with mailman user. ok i note it.
I ve seen this link about python script to manage mailman3 by shell : https://fog.ccsf.edu/~msapiro/scripts/ (thx you)
Regards,
On 23/09/2023 17:33, Mark Sapiro wrote:
On 9/23/23 07:40, testeur via Mailman-users wrote:
|# mailman shell -l testlist@domain.tld |
It looks like you are running
mailman shell
asroot
. You should always run mailman commands including starting mailman as the Mailman user, never as root. Running thing as root can create things that later can't be read by the mailman user.||>>> from mailman.interfaces.action import Action >>> for mbr in m.members.members: mbr.moderation_action = Action.defer |||commit()|
|||>>> from mailman.interfaces.action import Action |||||||>>> english = getUtility(ILanguageManager).get('en')| >>> for mbr in m.members.members: || mbr.preferences.acknowledge_posts = False mbr.preferences.delivery_mode = DeliveryMode.regular mbr.preferences.delivery_status = DeliveryStatus.enabled mbr.preferences.hide_address = False mbr.preferences.preferred_language = english mbr.preferences.receive_list_copy = False mbr.preferences.receive_own_postings = True|commit()||
I'm not sure what the above actually says. The interaction should look like
>>> from mailman.interfaces.action import Action >>> english = getUtility(ILanguageManager).get('en') >>> for mbr in m.members.members: ... mbr.preferences.acknowledge_posts = False ... mbr.preferences.delivery_mode = DeliveryMode.regular ... mbr.preferences.delivery_status = DeliveryStatus.enabled ... mbr.preferences.hide_address = False ... mbr.preferences.preferred_language = english ... mbr.preferences.receive_list_copy = False ... mbr.preferences.receive_own_postings = True ... >>> commit()
Actually, importing Action is not necessary as it is among the things defined by default in
mailman shell
in interactive mode.Before the shell command, the web interface was with an other language (i tested with italian one) and other options preferences, but after the shell command, after a web interface refresh, it doesn't change.
The above shell interaction sets the preferred_language for all list members to english. This has nothing to do with the language for the web UI. This is set by Django. See <https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#how-django-di...>.
participants (3)
-
Mark Sapiro
-
Stephen J. Turnbull
-
testeur