API Reference

class mailmanclient.Client(baseurl, name=None, password=None)[source]

Access the Mailman REST API root.

Parameters:
  • baseurl – The base url to access the Mailman 3 REST API.
  • name – The Basic Auth user name. If given, the password must also be given.
  • password – The Basic Auth password. If given the name must also be given.
bans

Get a list of all the bans.

Returns:A list of all the bans.
Return type:Bans
chains

Get a list of all the Chains.

Returns:A list of all the chains in Core.
Return type:List
configuration

Get the system configuration.

Returns:All the system configuration.
Return type:Dict[str, Configuration]
create_domain(mail_host, base_url=<object object>, description=None, owner=None, alias_domain=None)[source]

Create a new Domain.

Parameters:
  • mail_host (str) – The Mail host for the new domain. If you want foo@bar.com” as the address for your MailingList, use “bar.com” here.
  • description (str) – A brief description for this Domain.
  • owner (str) – Email address for the owner of this list.
  • alias_domain (str) – Alias domain.
Returns:

The created Domain.

Return type:

Domain

create_user(email, password, display_name='')[source]

Create a new User.

Parameters:
  • email (str) – Email address for the new user.
  • password (str) – Password for the new user.
  • display_name (str) – An optional name for the new user.
Returns:

The created user instance.

Return type:

User

delete_domain(mail_host)[source]

Delete a Domain.

Parameters:mail_host (str) – The Mail host for the domain you want to delete.
delete_list(fqdn_listname)[source]

Delete a MailingList.

Parameters:fqdn_listname (str) – Fully qualified name of the MailingList.
domains

Get a list of all Domains.

Returns:All the domains on the system.
Return type:List[Domain]
find_lists(subscriber, role=None, count=50, page=1)[source]

Given a subscriber and a role, return all the list they are subscribed to with given role.

If no role is specified all the related mailing lists are returned without duplicates, even though there can potentially be multiple memberships of a user in a single mailing list.

Parameters:
  • subscriber (str) – The address of the subscriber.
  • role (str) – owner, moderator or subscriber
Returns:

A filtered list of mailing lists with given filters.

Return type:

List[MailingList]

get_address(address)[source]

Given an Email Address, return the Address object.

Parameters:address (str) – Email address.
Returns:The Address object for given email address.
Return type:Address
get_bans_page(count=50, page=1)[source]

Get a list of all the bans with pagination.

Parameters:
  • count (int) – Number of entries per-page (defaults to 50).
  • page (int) – The page number to return (defaults to 1).
Returns:

Paginated list of banned addresses.

Return type:

Page of BannedAddress

get_domain(mail_host, web_host=<object object>)[source]

Get Domain by its mail_host.

get_list(fqdn_listname)[source]

Get a MailingList object.

Parameters:fqdn_listname (str) – Fully qualified name of the MailingList.
Returns:The mailing list object of the given fqdn_listname.
Return type:MailingList
get_list_page(count=50, page=1, advertised=None)[source]

Get a list of all MailingList with pagination.

Parameters:
  • count – Number of entries per-page (defaults to 50).
  • page – The page number to return (defaults to 1).
  • advertised – If marked True, returns all MailingLists including the ones that aren’t advertised.
get_lists(advertised=False)[source]

Get a list of all the MailingLists.

Parameters:advertised (bool) – If marked True, returns all MailingLists including the ones that aren’t advertised.
Returns:A list of mailing lists.
Return type:List(MailingList)
get_member(fqdn_listname, subscriber_address)[source]

Get the Member object for a given MailingList and Subsciber’s Email Address.

Parameters:
  • fqdn_listname (str) – Fully qualified address for the MailingList.
  • subscriber_address (str) – Email Address for the subscriber.
Returns:

A member of a list.

Return type:

Member

get_member_page(count=50, page=1)[source]

Return a paginated list of Members.

Parameters:
  • count (int) – Number of items to return.
  • page (int) – The page number.
Returns:

Paginated lists of members.

Return type:

Page of Member.

get_templates_page(count=25, page=1)[source]

Get paginated site-context templates.

Returns:Paginated list of templates of site context.
Return type:Page of Template
get_user(address)[source]

Given an Email Address, return the User it belongs to.

Parameters:address (str) – Email Address of the User.
Returns:The user instance that owns the address.
Return type:User
get_user_page(count=50, page=1)[source]

Get all the users with pagination.

Parameters:
  • count (int) – Number of entries per-page (defaults to 50).
  • page (int) – The page number to return (defaults to 1).
Returns:

Paginated list of users on Mailman.

Return type:

Page of User

lists

Get a list of all MailingLists.

Returns:All the mailing lists.
Return type:list(MailingList)
members

Get a list of all the Members.

Returns:All the list memebrs.
Return type:List[Member]
pipelines

Get a list of all Pipelines.

Returns:A list of all the pipelines in Core.
Return type:List
preferences

Get all default system Preferences.

Returns:System preferences.
Return type:Preferences
queues

Get a list of all Queues.

Returns:A list of all the queues in Core.
Return type:List
set_template(template_name, url, username=None, password=None)[source]

Set template in site-context.

Parameters:
  • template_name (str) – The template to set.
  • url (str) – The URL to fetch the template from.
  • username (str) – Username for access to the template.
  • password (str) – Password for the username to access templates.
styles

All the default styles in Mailman Core.

Returns:All the styles in Core.
Return type:Styles
system

Get the basic system information.

Returns:System information about Mailman Core
Return type:Dict[str, str]
templates

Get all site-context templates.

Returns:List of templates for the site context.
Return type:TemplateList
users

Get all the users.

Returns:All the users in Mailman Core.
Return type:List[User]
class mailmanclient.Domain(connection, url, data=None)[source]
add_owner(owner)[source]
base_url
create_list(list_name, style_name=None)[source]
get_list_page(count=50, page=1, advertised=None)[source]
get_lists(advertised=None)[source]
lists
owners
remove_all_owners()[source]
set_template(template_name, uri, username=None, password=None)[source]
templates
web_host
class mailmanclient.MailingList(connection, url, data=None)[source]
accept_message(request_id)[source]

Shortcut for moderate_message.

accept_request(request_id)[source]

Shortcut to accept a subscription request.

add_moderator(address, display_name=None)[source]
add_owner(address, display_name=None)[source]
add_role(role, address, display_name=None)[source]
archivers
bans
defer_message(request_id)[source]

Shortcut for moderate_message.

defer_request(request_id)[source]

Shortcut to defer a subscription request.

discard_message(request_id)[source]

Shortcut for moderate_message.

discard_request(request_id)[source]

Shortcut to discard a subscription request.

find_members(address=None, role=None, page=None, count=50)[source]
get_bans_page(count=50, page=1)[source]
get_held_message(held_id)[source]
get_held_page(count=50, page=1)[source]
get_member(email)[source]

Get a membership.

Parameters:address – The email address of the member for this list.
Returns:A member proxy object.
get_member_page(count=50, page=1)[source]
header_matches
held

Return a list of dicts with held message information.

is_member(address)[source]

Given an address, checks if the given address is subscribed to this mailing list.

is_moderator(address)[source]

Given an address, checks if the given address is a moderator of this mailing list.

is_owner(address)[source]

Given an address, checks if the given address is an owner of this mailing list.

is_owner_or_mod(address)[source]

Given an address, checks if the given address is either a owner or a moderator of this list.

It is possible for them to be both owner and moderator.

manage_request(token, action)[source]

Alias for moderate_request, kept for compatibility

members
moderate_message(request_id, action)[source]

Moderate a held message.

Parameters:
  • request_id (Int.) – Id of the held message.
  • action (String.) – Action to perform on held message.
moderate_request(request_id, action)[source]

Moderate a subscription request.

Parameters:action (str.) – accept|reject|discard|defer
moderators
nonmembers
owners
reject_message(request_id)[source]

Shortcut for moderate_message.

reject_request(request_id)[source]

Shortcut to reject a subscription request.

remove_moderator(address)[source]
remove_owner(address)[source]
remove_role(role, address)[source]
requests

Return a list of dicts with subscription requests.

set_template(template_name, uri, username=None, password=None)[source]
settings
subscribe(address, display_name=None, pre_verified=False, pre_confirmed=False, pre_approved=False)[source]

Subscribe an email address to a mailing list.

Parameters:
  • address (str) – Email address to subscribe to the list.
  • display_name (str) – The real name of the new member.
  • pre_verified (bool) – True if the address has been verified.
  • pre_confirmed (bool) – True if membership has been approved by the user.
  • pre_approved (bool) – True if membership is moderator-approved.
Returns:

A member proxy object.

templates
unsubscribe(email)[source]

Unsubscribe an email address from a mailing list.

Parameters:address – The address to unsubscribe.
class mailmanclient.ListArchivers(connection, url, mlist)[source]

Represents the activation status for each site-wide available archiver for a given list.

class mailmanclient.Bans(connection, url, data=None, mlist=None)[source]

The list of banned addresses from a mailing-list or from the whole site.

add(email)[source]
find_by_email(email)[source]
remove(email)[source]
class mailmanclient.BannedAddress(connection, url, data=None)[source]
mailinglist
class mailmanclient.HeaderMatches(connection, url, mlist)[source]

The list of header matches for a mailing-list.

add(header, pattern, action=None)[source]
Parameters:
  • header (str) – The header to consider.
  • pattern (str) – The regular expression to use for filtering.
  • action (str) – The action to take when the header matches the pattern. This can be ‘accept’, ‘discard’, ‘reject’, or ‘hold’.
class mailmanclient.HeaderMatch(connection, url, data=None)[source]
class mailmanclient.Member(connection, url, data=None)[source]
address
unsubscribe()[source]

Unsubscribe the member from a mailing list.

user
class mailmanclient.User(connection, url, data=None)[source]
add_address(email, absorb_existing=False)[source]

Adds another email adress to the user record and returns an _Address object.

Parameters:
  • email (str.) – The address to add
  • absorb_existing (bool.) – set this to True if you want to add the address even if it already exists. It will import the existing user into the current one, not overwriting any previously set value.
addresses
subscription_list_ids
subscriptions
class mailmanclient.Addresses(connection, url, data=None)[source]
find_by_email(email)[source]
remove(email)[source]
class mailmanclient.Address(connection, url, data=None)[source]
unverify()[source]
user
verified
verify()[source]
class mailmanclient.HeldMessage(connection, url, data=None)[source]
accept()[source]

Shortcut for moderate.

defer()[source]

Shortcut for moderate.

discard()[source]

Shortcut for moderate.

moderate(action)[source]

Moderate a held message.

Parameters:action (String.) – Action to perform on held message.
reject()[source]

Shortcut for moderate.

class mailmanclient.Preferences(connection, url, data=None)[source]
delete()[source]
class mailmanclient.Settings(connection, url, data=None)[source]
class mailmanclient.Queue(connection, url, data=None)[source]
files
inject(list_id, text)[source]