From 2f9907f24755b59ceb9ae075e26b1e4f606adeec Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 24 Nov 2021 10:53:49 +0100 Subject: mail: add a custom email policy Uses structured parsing for more headers. --- alot/mail/policy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 alot/mail/policy.py (limited to 'alot/mail/policy.py') diff --git a/alot/mail/policy.py b/alot/mail/policy.py new file mode 100644 index 00000000..1b9f07c3 --- /dev/null +++ b/alot/mail/policy.py @@ -0,0 +1,19 @@ +# This file is released under the GNU GPL, version 3 or a later revision. +# For further details see the COPYING file + +import email.policy as _p +import email.headerregistry as _hdr + +from . import headers as HDR + +_headers = { + HDR.X_BEEN_THERE : _hdr.UniqueAddressHeader, + HDR.X_MAILING_LIST : _hdr.UniqueAddressHeader, +} + +# here we define our custom policy that handles additional headers +# derive from SMTP +p = _p.EmailPolicy() + _p.SMTP + +for h, t in _headers.items(): + p.header_factory.map_to_type(h, t) -- cgit v1.2.3