Thanks, but no luck. Trying option 1, added custom_header.py file:
from mailman.interfaces.handler import IHandler from zope.interface import implementer
@implementer(IHandler) class AddCustomHeader: def process(self, mlist, message, msgdata): """Add a custom email header.""" message['X-Custom-Header-1'] = 'ABCD' logger.info('Custom header added to message for list: %s', mlist.fqdn_listname)
to /opt/mailman/venv/lib/python3.9/site-packages/mailman/handlers/
and modified /opt/mailman/venv/lib/python3.9/site-packages/mailman/pipelines/builtin.py:
class PostingPipeline(BasePipeline): """The built-in posting pipeline."""
name = 'default-posting-pipeline'
description = _('The built-in posting pipeline.')
_default_handlers = (
'validate-authenticity',
'mime-delete',
'tagger',
'member-recipients',
'avoid-duplicates',
'cleanse',
'cleanse-dkim',
'cook-headers',
'subject-prefix',
'rfc-2369',
'to-archive',
'to-digest',
'to-usenet',
'after-delivery',
'acknowledge',
# All decoration is now done in delivery.
# 'decorate',
'dmarc',
# Message decoration in delivery can break an arc signature, so sign
# in delivery after decorating.
# 'arc-sign',
'custom_header',
'to-outgoing',
)
Upon service restart got KeyError: 'custom_header':
Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 1077, in main Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: with self.make_context(prog_name, args, **extra) as ctx: Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 943, in make_context Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: self.parse_args(ctx, args) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 1644, in parse_args Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: rest = super().parse_args(ctx, args) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 1408, in parse_args Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: value, args = param.handle_parse_result(ctx, opts, args) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 2400, in handle_parse_result Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: value = self.process_value(ctx, value) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/click/core.py", line 2362, in process_value Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: value = self.callback(ctx, self, value) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/bin/mailman.py", line 95, in initialize_config Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: initialize(value) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/core/initialize.py", line 229, in initialize Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: initialize_2(propagate_logs=propagate_logs) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/core/initialize.py", line 198, in initialize_2 Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: initialize_pipelines() Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/core/pipelines.py", line 75, in initialize Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: add_components('pipelines', IPipeline, config.pipelines) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/utilities/modules.py", line 219, in add_components Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: component = component_class() Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: File "/opt/mailman/venv/lib64/python3.9/site-packages/mailman/pipelines/base.py", line 38, in __init__ Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: self._handlers.append(config.handlers[handler_name]) Oct 17 15:42:22 news.ivolatility.com mailman[1986181]: KeyError: 'custom_header' Oct 17 15:42:22 news.ivolatility.com systemd[1]: mailman3.service: Control process exited, code=exited, status=1/FAILURE