Here are some scripts that automate certain mailing list management tasks. They are written in Python.


The next four scripts require that you have Python installed on your workstation. The first three normally require Python 2.4 or later, but they will work with some earlier versions (2.0 +) if you have ClientCookie installed. The fourth requires Python3.

More information can be obtained by running the script with the --help option or just reading the beginning of the script.

Topica_Archives.py
Retrieve the archives of a lists.topica.com list in Unix mailbox format. Historical interest only as lists.topica.com is gone.
Topica_Subscribers.py
Retrieve a list of the subscribers of a lists.topica.com list along with real name, moderation and digest flags, etc. Historical interest only as lists.topica.com is gone.
mailman-subscribers.py
Obtain a list of subscribers to a Mailman list with various additional information.
mailman-subscribers3.py
A Python3 compatible version of mailman-subscribers.py.

The next script is a standalone Python script that can run anywhere that Python 2.7 or Python 3 is available.
subscribe_log
Analyze a Mailman 2.1 subscribe log. Report by listname and by email address, the most recent join and/or leave events within a given period or the entire log.
And these are standalone Python 3 scripts that can run anywhere that Python 3 is available.
check_hk_import
Read an archive mbox file to find and report any messages in the mbox that might throw possibly uncaught exceptions in hyperkitty_import.
cleanarch3
A Python 3 compatible version of mailman 2.1's bin/cleanarch script for escaping 'From ' lines in message bodies in Unix mbox files. This also includes the Date: check enhancements like the cleanarch2 script below.

The rest of the scripts do not require Python on your workstation. They run on the Mailman host machine. Thus, they require command line access to the Mailman installation.


The next script runs on a Mailman 3 host.

smtp_report
This script reads the two most recent generations of Mailman's smtp.log and produces a report by day and list of the total number of messages sent including administrivia.

The next scripts are stand alone Mailman 3 scripts. They have a shebang line which is intended to run them with the python installed in the venv in which Mailman is installed. This may need adjustment, or if Mailman is installed in a different way, you may need to cd to an appropriate directory before running the script. Also, there are some hard coded paths that may need adjustment. Finally, if your database is not PostgreSQL, the database access will need adjustment in some scripts.

clean_users.py
This script will delete Django users for which there is no corresponding Mailman user or optionally a Mailman user with no list memberships. It can also optionally delete Mailman users with no list memberships.
Mult_primary
This script reports on Django users that have multiple addresses, more than one of which is designated as primary or a user address that isn't primary. This can result from the UC_fix script.
prune_arch3
A simple script to delete messages from a HyperKitty archive which are older than a supplied date.
UC_fix
This script looks at django users' addresses and where there are two that differ only in case one of which is all lower case, it deletes the mixed case address and sets the lower case address primary. This is a workaround for this issue. See the Mult_primary script for reporting issues that result from this process.

The next scripts are Mailman 3 scripts designed to be run by the mailman shell command. See the beginning of the script for more information.

delete_dup_sub.py
Sometimes the same address gets subscribed to a list as both an address and as a user. This causes various issues. This script finds those cases and unsubscribes the address, leaving the user subscribed.
delete_orphans_expireds.py
Prior to Mailman 3.3.5, some tokens for user confirmations were pended with too long a lifetime. This script removes those pendings based on when they were pended and the configured pending_request_life rather than their expiration. Also prior to Mailman 3.3.5, pended held_message tokens for email handling of the message were not removed when the message was handled via REST. This script removes those pendings too.

The next scripts are designed to run from Mailman 2.1's bin/ directory in the same manner as Mailman's other command line tools. Run the script with the --help option for more information.

check_arch
Check an archive mbox for inconsistencies. This is a compliment to the standard bin/cleanarch. It checks and reports more anomalies than cleanarch, but it doesn't attempt to fix anything.
cleanarch2
An enhanced version of the standard Mailman bin/cleanarch which will also fix Date: headers which are unparseable or have dates more than ARCHIVER_ALLOWABLE_SANE_DATE_SKEW different from the Unix-From date.
clone_list
Create a clone of an existing list with a new name (requires python 2.7).
clone_list2
Like clone_list but works with python 2.5+. See comments in script for Python 2.3 and 2.4. If python 2.7 is available, clone_list is preferred as its argument parsing and help are more robust.
erase
Remove an address or all addresses matching a regexp from the installation. I.e. for every list, if the address is a member, it is removed. If there are any held posts or (un)subscription requests from the address, they are removed too. Optionally, any subscription requests from the address waiting user confirmation are also removed.
get_welcome
Reprint or remail the list welcome message for a user.
hddump
Dump the contents of a Pipermail archive database for a given list and archive volume. Possibly useful for diagnosing archive anomalies.
hdfix
A script for redacting selected message subjects and optionally author names in a Pipermail archive database.
held
Process held messages. Like bin/discard but allows accepting or rejecting as well as discarding the message(s) and optionally forwarding and/or preserving the processed message(s).
hold_again
If the request.pck entry corresponding to a heldmsg-LIST-nn.* held message file has been somehow lost so the held message is not in the admindb interface, this script can requeue the message from the heldmsg-LIST-nn.* file to the in queue so it will be reprocessed and presumably held again.
invite_members
A script based on the standard add_members script, but sends invitations instead of directly adding members. It also allows specifying additional text to be included at the top of the invitation.
list_pending
List the contents of the pending requests file for a Mailman list.
list_requests
List the outstanding moderator requests for a Mailman list or lists. Optionally accept, reject or discard each listed request or, also optionally, all remaining requests of that type for that list.
non_members
Add and or remove entries from one or more list's *_these_nonmembers filters.
old_helds
List various information about lists and their held posts for all lists that have held posts older than a specified number of days.
post_from_mbox
Post all the messages in a *nix mbox file to a list.
prune_arch
Prune older messages from the archives of one or more lists.
recode_list
Recode the strings in list attributes from one encoding to another. This is useful if Mailman's encoding for a list's preferred_language is changed.
remove_gzip
Remove *.txt.gz files from the archive and update the index to link to the *.txt files. Run after removing cron/nightly_gzip from the crontab.
remove_recips
List and/or remove recipients from a Mailman 'out' or 'retry' queue entry.
update_archive_mtime
Update the access and modification times of archived message files to match the archived time in the file.
user_options
Display the various options and settings for a member of a list. Works as is for Python 2.5+. See comment in the script for Python 2.3 and 2.4.
set_attributes
Unlike the other scripts in this section, this is a bash script which accepts arguments of the form "attribute = value" and invokes Mailman's bin/config_list to update those attributes for a list. This simplifies config_list usage for setting just one or a few things for a single list.

The next group of scripts are 'withlist' scripts that run under control of Mailman's bin/withlist script on the Mailman host machine.

See the first part of each script for additional information.

add_banned.py
Adds an address or regexp to the ban list of all lists.
change_admins.py
Set, add and/or remove owners and/or moderators of lists.
change_member_address.py
Changes a member's address.
clear_bounce_info.py
Clears bounce info for members with recorded bounces. Does not re-enable delivery. See reset_bounce.py for that.
created.py
Displays the created_at date for a list.
discard_address.py
Discards all held posts and held subscription requests from a given address.
discard_subs.py
Discards all held subscription requests older than a given number of days.
fix_bad_bounce_info.py
Removes bounce_info for any address that is not a list member. Normally, this situation should not occur. Also removes stale bounce info.
fix_data_version.py
Sometimes a site applies a patch to Mailman which adds and then uses new list attributes, but because the patch might be against an older release, it may not cause version updating to be done on existing lists. If that happens, this script will force version updating to be done for the list(s) it is run against.
fix_minus_one.py
Fixes the "-1 requests pending" bug in 2.1.5 if there are more lists affected than is convenient to fix by visiting the admindb pages.
fix_uc_address.py
Find all list members with upper case in their non-case preserved member email addresses and convert to lower case or remove them if the lower case member exists.
get_bounce_info.py
Prints the bounce information for all list members that have any.
https.py
An alternative to fix_url.py to set https scheme in web_page_url for all lists at once.
last_post.py
Displays the last post time for a list or all lists.
list_etc.py
List the contents of subscribe_auto_approval, ban_list and *_these_nonmembers for a list or lists.
list_mod.py
Lists either moderated or unmoderated members of a list. (Beginning in Mailman 2.1.21, bin/list_members can do this.)
rebuild_archtoc.py
Rebuilds the archive TOC page for a list or lists if *.txt.gz files have been removed and the TOC links are not to the *.txt files.
remove_bad_address.py
Removes syntactically invalid addresses from a list. This should normally only be required in cases where the address contains leading or trailing whitespace as the pipe
bin/list_members -i <listname> | bin/remove_members -f - <listname>
should suffice otherwise.
reset_bounce.py
Enables delivery for all members or all those in a given domain or those named members whose delivery is disabled by bounce.
set_ack.py
Sets the Acknowledge posts option for all regular member addresses on a list or lists that match a supplied argument.
set_dmarc.py
Raises the dmarc_moderation_action for a list or lists to the value of DEFAULT_DMARC_MODERATION_ACTION if the list setting is lower.
set_mime.py
Set every list member's digest format to MIME and set the list's mime_is_default_digest to MIME.
set_mod.py
Set or unset moderation for one or more members on a list.
set_nodigest.py
Set a list's digestable flag to No and set all current digest members to regular delivery.
set_nodups.py
Sets all list members to not receive from the list those posts in which they are directly addressed in To: or Cc:
set_nomail.py
Sets a list member's delivery to 'disabled by admin' or optionally sets to 'disabled by bounce' and starts the notification and deletion process.
set_passwd.py
Set one or more of a list's admin, moderator or poster passwords.
set_plain.py
Set every list member's digest format to plain and set the list's mime_is_default_digest to plain.
set_unhide.py
Sets all members of a list to be 'unhidden'.
test_handler.py
Test the actions of a custom or standard handler against a test list and message.

These scripts are custom handlers. See the FAQ at http://wiki.list.org/x/l4A9 for information on custom handler installation.

See the first part of each script for additional information.

MoreHolds.py
Implements holds for messages with no Subject:, messages which quote digest boiler plate and (experimental) messages which quote excessively. Also see rejectquote.txt for a sample reject message template used by this script.
PostLimit.py
Implements a per time period limit for a member's posts to a list and/or total posts to the list.
GlobalTooBig.py
Implements a global maximum message size.