Mailman

raw JSON →
3.3.10 verified Fri May 01 auth: no python

Mailman is the GNU mailing list manager, a Python library for running and managing mailing lists. Current version 3.3.10, released periodically with bug fixes and improvements.

pip install mailman
error ImportError: No module named mailman
cause mailman is not installed or not in Python path.
fix
pip install mailman
error ConfigurationError: No configuration file found.
cause config.load() called without a valid path or MAILMAN_CONFIG not set.
fix
Set MAILMAN_CONFIG environment variable or pass path existing cfg file.
error KeyError: 'my-list'
cause The list does not exist in the database.
fix
Create the list first via REST API or mailman.core.initialize.
breaking Mailman 3.x is a complete rewrite from 2.x; APIs are not compatible. Do not expect Mailman 2.x patterns to work.
fix Use the new REST API and library interfaces. See documentation for migration.
deprecated Direct database manipulation is deprecated; use the REST API or the library's public interfaces.
fix Use mailman.client (REST client) or mailman.interfaces for operations.
gotcha Configuration must be loaded before accessing any components. Forgetting config.load() will raise errors.
fix Always call config.load('/path/to/mailman.cfg') early in your script.

Initialize Mailman from config and access a mailing list.

import os
from mailman.config import config

# Initialize with a configuration file
config.load(os.environ.get('MAILMAN_CONFIG', '/etc/mailman.cfg'))

# Get a mailing list instance (example)
from mailman.interfaces import IMailingList
# Assuming a list exists
list_name = 'my-list'
mlist = config.db.list_store.get(list_name)
print(f'List: {mlist.fqdn_listname}')