Skip to content

Instantly share code, notes, and snippets.

@emsearcy
Last active March 26, 2018 20:36
Show Gist options
  • Save emsearcy/428815893dffae6202d70a4a9115d02b to your computer and use it in GitHub Desktop.
Save emsearcy/428815893dffae6202d70a4a9115d02b to your computer and use it in GitHub Desktop.
Set DMARC mitigation for all Mailman 2 lists
#!/usr/bin/python
#
# Eric Searcy
# github.com/emsearcy
"""Ensure all mailing lists have DMARC mitigation enabled
Set 'DEFAULT_DMARC_MODERATION_ACTION = 1' in mm_cfg.py to set policy for future
changes.
This script is intended to be run as a bin/withlist script, i.e.
% sudo -u mailman bin/withlist -l -r set_dmarc -a
"""
from Mailman.i18n import C_
def set_dmarc(mlist, *args):
if mlist.dmarc_moderation_action == 0:
mlist.dmarc_moderation_action = 1
print C_('Saving list')
mlist.Save()
else:
print C_('Not saving: set to '+repr(mlist.dmarc_moderation_action))
mlist.Unlock()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment