[Remail] [PATCH 2/3] Fix default list-id value to conform to RFC2919

konstantin at linuxfoundation.org konstantin at linuxfoundation.org
Wed Nov 27 02:27:54 CET 2019


From: Konstantin Ryabitsev <konstantin at linuxfoundation.org>

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

Link: https://tools.ietf.org/html/rfc2919
Signed-off-by: Konstantin Ryabitsev <konstantin at linuxfoundation.org>
---
 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'] = '<mailto:%s-owner@%s>' % (addr, domain)
     headers['List-Post'] = '<mailto:%s>' % 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)
-- 
2.23.0




More information about the Remail mailing list