Mailing lists

The mailing list is a core object in Mailman. It is uniquely identified in the system by its list-id which is derived from its posting address, i.e. the email address you would send a message to in order to post a message to the mailing list. The list id is defined in RFC 2369.

>>> mlist = create_list('aardvark@example.com')
>>> print(mlist.list_id)
aardvark.example.com
>>> print(mlist.fqdn_listname)
aardvark@example.com

The mailing list also has convenient attributes for accessing the list’s short name (i.e. local part) and host name.

>>> print(mlist.list_name)
aardvark
>>> print(mlist.mail_host)
example.com

Rosters

Mailing list membership is represented by rosters. Each mailing list has several rosters of members, representing the subscribers to the mailing list, the owners, the moderators, and so on. The rosters are defined by a membership role.

Addresses can be explicitly subscribed to a mailing list. By default, a subscription puts the address in the member role, meaning that address will receive a copy of any message sent to the mailing list.

>>> from mailman.interfaces.usermanager import IUserManager
>>> from zope.component import getUtility
>>> user_manager = getUtility(IUserManager)

>>> aperson = user_manager.create_address('aperson@example.com')
>>> bperson = user_manager.create_address('bperson@example.com')
>>> mlist.subscribe(aperson)
<Member: aperson@example.com on aardvark@example.com as MemberRole.member>
>>> mlist.subscribe(bperson)
<Member: bperson@example.com on aardvark@example.com as MemberRole.member>

Both addresses appear on the roster of members.

>>> from operator import attrgetter
>>> sort_key = attrgetter('address.email')
>>> for member in sorted(mlist.members.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.member>
<Member: bperson@example.com on aardvark@example.com as MemberRole.member>

By explicitly specifying the role of the subscription, an address can be added to the owner and moderator rosters.

>>> from mailman.interfaces.member import MemberRole
>>> mlist.subscribe(aperson, MemberRole.owner)
<Member: aperson@example.com on aardvark@example.com as MemberRole.owner>
>>> cperson = user_manager.create_address('cperson@example.com')
>>> mlist.subscribe(cperson, MemberRole.owner)
<Member: cperson@example.com on aardvark@example.com as MemberRole.owner>
>>> mlist.subscribe(cperson, MemberRole.moderator)
<Member: cperson@example.com on aardvark@example.com
         as MemberRole.moderator>

A Person is now both a member and an owner of the mailing list. C Person is an owner and a moderator.

>>> for member in sorted(mlist.owners.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.owner>
<Member: cperson@example.com on aardvark@example.com as MemberRole.owner>

>>> for member in mlist.moderators.members:
...     print(member)
<Member: cperson@example.com on aardvark@example.com
         as MemberRole.moderator>

All rosters can also be accessed indirectly.

>>> roster = mlist.get_roster(MemberRole.member)
>>> for member in sorted(roster.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.member>
<Member: bperson@example.com on aardvark@example.com as MemberRole.member>

>>> roster = mlist.get_roster(MemberRole.owner)
>>> for member in sorted(roster.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.owner>
<Member: cperson@example.com on aardvark@example.com as MemberRole.owner>

>>> roster = mlist.get_roster(MemberRole.moderator)
>>> for member in roster.members:
...     print(member)
<Member: cperson@example.com on aardvark@example.com
         as MemberRole.moderator>

Subscribing users

An alternative way of subscribing to a mailing list is as a user with a preferred address. This way the user can change their subscription address just by changing their preferred address.

The user must have a preferred address.

>>> from mailman.utilities.datetime import now
>>> user = user_manager.create_user('dperson@example.com', 'Dave Person')
>>> address = list(user.addresses)[0]
>>> address.verified_on = now()
>>> user.preferred_address = address

The preferred address is used in the subscription.

>>> mlist.subscribe(user)
<Member: Dave Person <dperson@example.com> on aardvark@example.com
         as MemberRole.member>
>>> for member in sorted(mlist.members.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.member>
<Member: bperson@example.com on aardvark@example.com as MemberRole.member>
<Member: Dave Person <dperson@example.com> on aardvark@example.com
         as MemberRole.member>

If the user’s preferred address changes, their subscribed email address also changes automatically.

>>> new_address = user.register('dave.person@example.com')
>>> new_address.verified_on = now()
>>> user.preferred_address = new_address

>>> for member in sorted(mlist.members.members, key=sort_key):
...     print(member)
<Member: aperson@example.com on aardvark@example.com as MemberRole.member>
<Member: bperson@example.com on aardvark@example.com as MemberRole.member>
<Member: dave.person@example.com on aardvark@example.com
         as MemberRole.member>

A user is allowed to explicitly subscribe again with a specific address, even if this address is their preferred address.

>>> mlist.subscribe(user.preferred_address)
<Member: dave.person@example.com
         on aardvark@example.com as MemberRole.member>

MailingList Attributes

This defines all the attributes of a MailingList.

interface mailman.interfaces.mailinglist.IMailingList[source]

A mailing list.

acceptable_aliases = <zope.interface.interface.Attribute object>

List of addresses and regexps acceptable as explicit destination.

This is a list of addresses and regexps matching addresses that are acceptable in To: or Cc: when require_explicit_destination is True.

admin_immed_notify = <zope.interface.interface.Attribute object>

Flag controlling immediate notification of requests.

List moderators normally get daily notices about pending administrative requests. This flag controls whether moderators also receive immediate notification of such pending requests.

admin_notify_mchanges = <zope.interface.interface.Attribute object>

Flag controlling notification of joins and leaves.

List moderators can receive notifications for every member that joins or leaves their mailing lists. This flag controls those notifications.

administrators = <zope.interface.interface.Attribute object>

The IUser administrators of this mailing list.

This includes the IUsers who are both owners and moderators of the mailing list.

administrivia = <zope.interface.interface.Attribute object>

Flag controlling administrivia checks.

Administrivia tests check whether postings to the mailing list are really meant for the -request address. Examples include messages with help, subscribe, unsubscribe, and other commands. When such messages are incorrectly posted to the general mailing list, they are just noise, and when this flag is set will be intercepted and in general held for moderator approval.

advertised = <zope.interface.interface.Attribute object>

Advertise this mailing list when people ask for an overview of the available mailing lists.

allow_list_posts = <zope.interface.interface.Attribute object>

Flag specifying posts to the list are generally allowed.

This controls the value of the RFC 2369 List-Post header. This is usually set to True, except for announce-only lists. When False, the List-Post is set to NO as per the RFC.

anonymous_list = <zope.interface.interface.Attribute object>

Flag controlling whether messages to this list are anonymized.

Anonymizing messages is not perfect, however setting this flag removes the sender of the message (in the From, Sender, and Reply-To fields) and replaces these with the list’s posting address.

archive_policy = <zope.interface.interface.Attribute object>

The policy for archiving messages to this mailing list.

The value is an ArchivePolicy enum. Use this to archive the mailing list publicly, privately, or not at all.

autorespond_owner = <zope.interface.interface.Attribute object>

How should the mailing list automatically respond to messages sent to the -owner or -moderator address?

Options are: * No response sent * Send a response and discard the original messge * Send a response and continue processing the original message

autorespond_postings = <zope.interface.interface.Attribute object>

How should the mailing list automatically respond to messages sent to the list’s posting address?

Options are: * No response sent * Send a response and discard the original messge * Send a response and continue processing the original message

autorespond_requests = <zope.interface.interface.Attribute object>

How should the mailing list automatically respond to messages sent to the list’s -request address?

Options are: * No response sent * Send a response and discard the original messge * Send a response and continue processing the original message

autoresponse_grace_period = <zope.interface.interface.Attribute object>

Time period (in days) between automatic responses.

When this mailing list is set to send an auto-response for messages sent to mailing list posts, the mailing list owners, or the -request address, such reponses will not be sent to the same user more than once during the grace period. Set to zero (or a negative value) for no grace period (i.e. auto-respond to every message).

autoresponse_owner_text = <zope.interface.interface.Attribute object>

The text sent in an autoresponse to the owner or moderator.

autoresponse_postings_text = <zope.interface.interface.Attribute object>

The text sent in an autoresponse to the list’s posting address.

autoresponse_request_text = <zope.interface.interface.Attribute object>

The text sent in an autoresponse to the list’s -request address.

bounce_info_stale_after = <zope.interface.interface.Attribute object>

Number of days after which bounce info is considered stale.

The number of days after which a member’s bounce information is considered stale. If no new bounces have been received in the interim, the bounce score is reset to zero. This value must be an integer.

bounce_notify_owner_on_disable = <zope.interface.interface.Attribute object>

This option controls whether or not the list owner is notified when a member’s subscription is automatically disabled due to their bounce threshold being reached.

bounce_notify_owner_on_removal = <zope.interface.interface.Attribute object>

This option controls whether or not the list owner is notified when a member is removed from the list after their disabled notifications have been exhausted.

bounce_score_threshold = <zope.interface.interface.Attribute object>

Bounce score threshold for a mailing-list.

Threshold value for a Member’s bounce_score after which we will either disable membership or unsubscribe the member from the mailing list.

bounce_you_are_disabled_warnings = <zope.interface.interface.Attribute object>

The number of notices a disabled member will receive before their address is removed from the mailing list’s roster. Set this to 0 to immediately remove an address from the list once their bounce score exceeds the threshold. This value must be an integer.

bounce_you_are_disabled_warnings_interval = <zope.interface.interface.Attribute object>

The number of days between each disabled notification.

bounces_address = <zope.interface.interface.Attribute object>

The address which reaches the automated bounce processor for this mailing list. Generally, humans should never respond directly to this address.

collapse_alternatives = <zope.interface.interface.Attribute object>

Flag specifying whether multipart/alternatives should be collapsed.

After all MIME content filtering is complete, collapsing alternatives replaces the outer multipart/alternative parts with the first subpart.

confirm_address(cookie='')

The address used for various forms of email confirmation.

convert_html_to_plaintext = <zope.interface.interface.Attribute object>

Flag specifying whether text/html parts should be converted.

When True, after filtering, if there are any text/html parts left in the original message, they are converted to text/plain.

created_at = <zope.interface.interface.Attribute object>

The date and time that the mailing list was created.

data_path = <zope.interface.interface.Attribute object>

The file system path to list-specific data.

An example of list-specific data is the temporary digest mbox file that gets created to accumlate messages for the digest.

default_member_action = <zope.interface.interface.Attribute object>

The default action to take for postings from members.

When an address is subscribed to the mailing list, this attribute sets the initial moderation action (as an Action). When the action is Action.defer (the default), then normal posting decisions are made. When the action is Action.accept, the postings are accepted without any other checks.

default_nonmember_action = <zope.interface.interface.Attribute object>

The default action to take for postings from nonmembers.

When a nonmember address posts to the mailing list, this attribute sets the initial moderation action (as an Action). When the action is Action.defer (the default), then normal posting decisions are made. When the action is Action.accept, the postings are accepted without any other checks.

description = <zope.interface.interface.Attribute object>

A terse phrase identifying this mailing list.

This description is used when the mailing list is listed with other mailing lists, or in headers, and so forth. It should be as succinct as you can get it, while still identifying what the list is.

digest_last_sent_at = <zope.interface.interface.Attribute object>

The date and time a digest of this mailing list was last sent.

digest_members = <zope.interface.interface.Attribute object>

A roster of all the IMembers who are to receive digests of postings to this mailing list, regardless of whether they have their deliver disabled or not, or of the type of digest they are to receive.

digest_send_periodic = <zope.interface.interface.Attribute object>

Should a digest be sent by the mailman send_digest command even when the size threshold hasn’t yet been met?

digest_size_threshold = <zope.interface.interface.Attribute object>

The maximum (approximate) size in kilobytes of the digest currently being collected.

digest_volume_frequency = <zope.interface.interface.Attribute object>

How often should a new digest volume be started?

digests_enabled = <zope.interface.interface.Attribute object>

Whether or not digests are enabled for this mailing list.

display_name = <zope.interface.interface.Attribute object>

The short human-readable descriptive name for the mailing list. This is used in locations such as the message footers and as the default value for the Subject prefix.

dmarc_mitigate_action = <zope.interface.interface.Attribute object>

The mitigation to apply to messages from a DMARC matching domain.

This is a DMARCMitigateAction to be applied to messages From: a domain publishing DMARC p=reject or quarantine, and possibly unconditionally depending on the setting of dmarc_mitigate_unconditionally.

dmarc_mitigate_unconditionally = <zope.interface.interface.Attribute object>

Should DMARC mitigations apply unconditionally?

A flag indicating whether to apply dmarc_mitigate_action to all messages, but only if dmarc_mitigate_action is other than reject or discard.

dmarc_moderation_notice = <zope.interface.interface.Attribute object>

Text to include in any DMARC rejected message.

Rejection notices are sent when DMARCMitigateAction of reject applies.

dmarc_wrapped_message_text = <zope.interface.interface.Attribute object>

Additional MIME text to include in DMARC wrapped messages.

This text is added as a separate text/plain MIME part preceding the original message part in the wrapped message when DMARCMitigateAction of wrap_message applies.

domain = <zope.interface.interface.Attribute object>

The IDomain that this mailing list is defined in.

filter_action = <zope.interface.interface.Attribute object>

Action to take when the top-level content-type is filtered.

The value is a FilterAction enum.

filter_content = <zope.interface.interface.Attribute object>

Flag specifying whether to filter a message’s content.

Filtering is performed on MIME type and file name extension.

filter_extensions = <zope.interface.interface.Attribute object>

Sequence of file extensions that should be filtered out.

Set this attribute to a sequence to change it, or to None to empty it.

filter_types = <zope.interface.interface.Attribute object>

Sequence of MIME types that should be filtered out.

These can be either main types or main/sub types. Set this attribute to a sequence to change it, or to None to empty it.

forward_unrecognized_bounces_to = <zope.interface.interface.Attribute object>

What to do when a bounce contains no recognizable addresses.

This is an enumeration which specifies what to do with such bounce messages. They can be discarded, forward to the list owner, or forwarded to the site owner.

fqdn_listname = <zope.interface.interface.Attribute object>

The read-only fully qualified name of the mailing list. This is the guaranteed unique id for the mailing list, and it is always the address to which messages are posted, e.g. mylist@example.com. It is always comprised of the list_name + ‘@’ + mail_host.

gateway_to_mail = <zope.interface.interface.Attribute object>

Flag indicating that posts to the linked newsgroup should be gated to the list.

gateway_to_news = <zope.interface.interface.Attribute object>

Flag indicating that posts to the list should be gated to the linked newsgroup.

get_roster(role)

Return the appropriate roster for the given role.

Parameters:role (MemberRole) – The requested roster’s role.
Returns:The requested roster.
Return type:Roster
include_rfc2369_headers = <zope.interface.interface.Attribute object>

Flag specifying whether to include any RFC 2369 header, including the RFC 2919 List-ID header.

info = <zope.interface.interface.Attribute object>

A longer description of this mailing list. This can be any arbitrary text, up to a database-specific maximum length.

is_subscribed(subscriber, role=<MemberRole.member: 1>)

Is the given address or user subscribed to the mailing list?

Parameters:
  • subscriber (IUser or IAddress) – The address or user to check.
  • role (MemberRole) – The role being checked (e.g. a member, owner, or moderator of a mailing list).
Returns:

A flag indicating whether the subscriber is already subscribed to the mailing list or not.

join_address = <zope.interface.interface.Attribute object>

The address to which subscription requests should be sent.

last_digest_recipients = <zope.interface.interface.Attribute object>

An iterator over the addresses that should receive one last digest.

Items are 2-tuples of (IAddress, DeliveryMode). The one last digest recipients are cleared.

last_post_at = <zope.interface.interface.Attribute object>

The date and time a message was last posted to the mailing list.

leave_address = <zope.interface.interface.Attribute object>

The address to which unsubscription requests should be sent.

linked_newsgroup = <zope.interface.interface.Attribute object>

The name of the linked newsgroup.

list_id = <zope.interface.interface.Attribute object>

The identity of the mailing list. This value will never change. It is defined in RFC 2369.

list_name = <zope.interface.interface.Attribute object>

The read-only short name of the mailing list. Note that where a Mailman installation supports multiple domains, this short name may not be unique. Use the fqdn_listname attribute for a guaranteed unique id for the mailing list. This short name is always the local part of the posting email address. For example, if messages are posted to mylist@example.com, then the list_name is ‘mylist’.

mail_host = <zope.interface.interface.Attribute object>

The read-only domain name ‘hosting’ this mailing list. This is always the domain name part of the posting email address, and it may bear no relationship to the web url used to access this mailing list. For example, if messages are posted to mylist@example.com, then the mail_host is ‘example.com’.

member_roster_visibility = <zope.interface.interface.Attribute object>

The policy for who can view the member roster of this mailing list.

The value is an RosterVisibility enum. Use this to change who can view the member list. Options are public, members, or moderators.

members = <zope.interface.interface.Attribute object>

A roster of all the members of the mailing list, regardless of whether they are to receive regular messages or digests, or whether they have their delivery disabled or not.

moderators = <zope.interface.interface.Attribute object>

The IUser moderators of this mailing list.

This does not include the IUsers who are owners but not moderators of the mailing list.

newsgroup_moderation = <zope.interface.interface.Attribute object>

The moderation policy for the linked newsgroup, if there is one.

next_digest_number = <zope.interface.interface.Attribute object>

A sequence number for a specific digest in a given volume. When the digest volume number is bumped, the digest number is reset to 1.

nntp_prefix_subject_too = <zope.interface.interface.Attribute object>

Flag indicating whether the list’s subject_prefix should be included in posts gated to usenet.

no_reply_address = <zope.interface.interface.Attribute object>

The address to which all messages will be immediately discarded, without prejudice or record. This address is specific to the ddomain, even though it’s available on the IMailingListAddresses interface. Generally, humans should never respond directly to this address.

nonmembers = <zope.interface.interface.Attribute object>

A roster of all the nonmembers of the mailing list.

owner_address = <zope.interface.interface.Attribute object>

The address which reaches the owners and moderators of the mailing list. There is no address which reaches just the owners or just the moderators of a mailing list.

owner_chain = <zope.interface.interface.Attribute object>

This mailing list’s owner moderation chain.

When messages are posted to the owners of a mailing list, it first goes through a moderation chain to determine whether the message will be accepted. This attribute names a chain for postings, which must exist.

owner_pipeline = <zope.interface.interface.Attribute object>

This mailing list’s owner posting pipeline.

Every mailing list has a processing pipeline that messages flow through once they’ve been accepted for posting to the owners of a mailing list. This attribute names a pipeline for postings, which must exist.

owners = <zope.interface.interface.Attribute object>

The IUser owners of this mailing list.

This does not include the IUsers who are moderators but not owners of the mailing list.

pass_extensions = <zope.interface.interface.Attribute object>

Sequence of file extensions to explicitly pass.

Set this attribute to a sequence to change it, or to None to empty it. Pass extensions are consulted after filter extensions, and only if pass_extensions is non-empty.

pass_types = <zope.interface.interface.Attribute object>

Sequence of MIME types to explicitly pass.

These can be either main types or main/sub types. Set this attribute to a sequence to change it, or to None to empty it. Pass types are consulted after filter types, and only if pass_types is non-empty.

personalize = <zope.interface.interface.Attribute object>

The type of personalization that is applied to postings.

post_id = <zope.interface.interface.Attribute object>

A monotonically increasing integer sequentially assigned to each list posting.

posting_address = <zope.interface.interface.Attribute object>

The address to which messages are posted for copying to the full list membership, where ‘full’ of course means those members for which delivery is currently enabled.

posting_chain = <zope.interface.interface.Attribute object>

This mailing list’s posting moderation chain.

When messages are posted to a mailing list, it first goes through a moderation chain to determine whether the message will be accepted. This attribute names a chain for postings, which must exist.

posting_pipeline = <zope.interface.interface.Attribute object>

This mailing list’s posting pipeline.

Every mailing list has a processing pipeline that messages flow through once they’ve been accepted for posting to the mailing list. This attribute names a pipeline for postings, which must exist.

preferred_language = <zope.interface.interface.Attribute object>

The default language for communications on this mailing list.

When the list sends out notifications, it will be in this language, unless the recipient is a known user and that user has a preferred language.

process_bounces = <zope.interface.interface.Attribute object>

Whether or not the mailing list processes bounces.

regular_members = <zope.interface.interface.Attribute object>

An roster of all the IMembers who are to receive regular postings (i.e. non-digests) from the mailing list, regardless of whether they have their delivery disabled or not.

reply_goes_to_list = <zope.interface.interface.Attribute object>

Reply-To: header munging policy.

request_address = <zope.interface.interface.Attribute object>

The address which reaches the email robot for this mailing list. This robot can process various email commands such as changing delivery options, getting information or help about the mailing list, or processing subscrptions and unsubscriptions (although for the latter two, it’s better to use the join_address and leave_address.

require_explicit_destination = <zope.interface.interface.Attribute object>

Flag controlling requiring explisit destination.

If require_explicit_destination is True, a post must have the list’s posting address or an acceptable alias in To: or Cc: or be held for moderator approval.

send_goodbye_message = <zope.interface.interface.Attribute object>

Flag indicating whether a goodbye message should be sent.

send_one_last_digest_to(address, delivery_mode)

Make sure to send one last digest to an address.

This is used when a person transitions from digest delivery to regular delivery and wants to make sure they don’t miss anything. By indicating that they’d like to receive one last digest, they will ensure continuity in receiving mailing lists posts.

Parameters:
  • address (IAddress) – The address of the person receiving one last digest.
  • delivery_mode (DeliveryMode) – The type of digest to receive.
send_welcome_message = <zope.interface.interface.Attribute object>

Flag indicating whether a welcome message should be sent.

subject_prefix = <zope.interface.interface.Attribute object>

The text to insert at the front of the Subject field.

When messages posted to this mailing list are sent to the list subscribers, the Subject header may be rewritten to include an identifying prefix. Typically this prefix will appear in square brackets and the default value inside the brackets is taken as the list’s display name. However, any value can be used, including the empty string to prevent Subject header rewriting.

subscribe(subscriber, role=<MemberRole.member: 1>)

Subscribe the given address or user to the mailing list.

Parameters:
  • subscriber (IUser or IAddress) – The address or user to subscribe to the mailing list. The user’s preferred address receives deliveries, if she has one, otherwise no address for the user appears in the rosters.
  • role (MemberRole) – The role being subscribed to (e.g. a member, owner, or moderator of a mailing list).
Returns:

The member object representing the subscription.

Return type:

IMember

Raises:
  • AlreadySubscribedError – If the address or user is already subscribed to the mailing list with the given role. Note however that it is possible to subscribe an address to a mailing list with a particular role, and also subscribe a user with a matching preferred address that is explicitly subscribed with the same role.
  • InvalidEmailAddressError – If the address being subscribed is the list’s posting address.
subscribe_address = <zope.interface.interface.Attribute object>

Deprecated address to which subscription requests may be sent. This address is provided for backward compatibility only. See join_address for the preferred alias.

subscribers = <zope.interface.interface.Attribute object>

An iterator over all IMembers subscribed to this list, with any role.

subscription_policy = <zope.interface.interface.Attribute object>

The policy for subscribing new members to the list.

unsubscribe_address = <zope.interface.interface.Attribute object>

Deprecated address to which unsubscription requests may be sent. This address is provided for backward compatibility only. See leave_address for the preferred alias.

unsubscription_policy = <zope.interface.interface.Attribute object>

The policy for unsubscribing members from the list.

usenet_watermark = <zope.interface.interface.Attribute object>

The NNTP server’s message number of the last post gated to the list.

volume = <zope.interface.interface.Attribute object>

A monotonically increasing integer sequentially assigned to each new digest volume. The volume number may be bumped either automatically (i.e. on a defined schedule) or manually. When the volume number is bumped, the digest number is always reset to 1.