From 18a16b08fb8e72e446a4f7a7cf9b4a92d45ad1cb Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 26 Nov 2019 20:27:54 -0500 Subject: [PATCH] remail: Fix default list-id value to conform to RFC2919 According to RFC2919, List-Id header should be in the form of a hostname value enclosed inside angle brackets. This change does two things: 1. Fixes the default to be the list address with "@" replaced by a "." 2. Allows setting custom list-id values inside remail.yaml 3. Documents the "listid" optional setting in the manpage Signed-off-by: Konstantin Ryabitsev Signed-off-by: Thomas Gleixner Link: https://tools.ietf.org/html/rfc2919 --- Documentation/man5/remail.config.rst | 6 ++++++ remail/config.py | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/man5/remail.config.rst b/Documentation/man5/remail.config.rst index c08dc6b..43a3843 100644 --- a/Documentation/man5/remail.config.rst +++ b/Documentation/man5/remail.config.rst @@ -257,6 +257,7 @@ The list base configuration for each list consists of the following items: listname: enabled: True moderated: True + listid: ... archive: ... listaccount: @@ -286,6 +287,11 @@ The list base items: with a subscriber. Mails from non-subscribers are not delivered to the list, they are delivered to the list administrator + listid: + + Optional item to override the default list-id with a custom value. + Default: list address with the "@" replaced by a period. + The archive section: """""""""""""""""""" diff --git a/remail/config.py b/remail/config.py index a0bf7f8..d58b88c 100644 --- a/remail/config.py +++ b/remail/config.py @@ -120,10 +120,10 @@ def list_account_config(cfgdict, base): raise RemailListConfigException(txt) return laccs.pop() -def build_listheaders(mailaddr): +def build_listheaders(mailaddr, listid): addr, domain = mailaddr.split('@') headers = {} - headers['List-Id'] = mailaddr + headers['List-Id'] = '<%s>' % listid headers['List-Owner'] = '' % (addr, domain) headers['List-Post'] = '' % mailaddr return headers @@ -280,7 +280,8 @@ class list_config(object): self.listaccount = list_account_config(acc, base + '.listaccount') self.listaddrs = listaddrs(self.listaccount.addr) - self.listheaders = build_listheaders(self.listaccount.addr) + listid = cfgdict.get('listid', self.listaccount.addr.replace('@', '.')) + self.listheaders = build_listheaders(self.listaccount.addr, listid) self.smime = smime_config(self.listdir, None) self.gpg = gpg_config(self.listdir, None)