Difference between revisions of "Mailman 3 Shell"

From Run Your Own
Jump to: navigation, search
(Change the default max email size)
(List all the subscribed emails from all lists)
Line 25: Line 25:
 
  ...
 
  ...
 
  <lots of stuff>
 
  <lots of stuff>
 +
 +
=== Re-enable accounts that have been disabled for excess bounce ===
 +
su mailman
 +
cd ~/env
 +
mailman shell -l listname@we.lurk.org
 +
>>> for member in m.members.members:
 +
...    if member.delivery_status == DeliveryStatus.by_bounces:
 +
...        member.preferences.delivery_status = DeliveryStatus.enabled
 +
...        print("Re-enabled delivery for bouncing member {} on list {}"
 +
...              .format(member.address.email, mlist.list_name))
 +
...
 +
<lots of stuff>
 +
>>> commit()
 +
>>> exit()
  
 
[[Category:Email]]
 
[[Category:Email]]

Revision as of 12:12, 19 July 2023

Mailman 3 comes with a shell that allows to work directly on a list from Python's REPL. Use it wisely.

Troubleshooting

Step by step example: change the size of message attachments

  • become the mailman
su mailman
  • go to the venv home (important!)
cd ~/env
  • start the shell with the list, the settings of which you want to edit:
mailman withlist mylist@we.lurk.org
  • assign new value to max_message_size. Each unit is 1024 bytes, so 500K would be simply
m.max_message_size = 500
  • quit the shell
exit()  # or Ctrl-D
  • Done! Enjoy your mailchimp forwards!

List all the subscribed emails from all lists

su mailman
cd ~/env
mailman shell 
>>> lm = getUtility(IListManager)
>>> for mlist in lm.mailing_lists:
...     for member in mlist.members.members:
...             print(member.address.email, mlist.list_name)
...
<lots of stuff>

Re-enable accounts that have been disabled for excess bounce

su mailman
cd ~/env
mailman shell -l listname@we.lurk.org
>>> for member in m.members.members:
...     if member.delivery_status == DeliveryStatus.by_bounces:
...         member.preferences.delivery_status = DeliveryStatus.enabled
...         print("Re-enabled delivery for bouncing member {} on list {}"
...               .format(member.address.email, mlist.list_name))
...
<lots of stuff>
>>> commit()
>>> exit()