From c2d45a47fe96b5093f5f2ee3f34ec41c8dfb93de Mon Sep 17 00:00:00 2001 From: Dario Ernst Date: Thu, 27 Dec 2018 15:36:24 +0100 Subject: [PATCH] Attempt stripping recipient delimiter from localpart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since postfix now asks us for the complete email over podop, which includes the recipient-delimiter-and-what-follows not stripped, we need to attempt to find both the verbatim localpart, as well as the localpart stripped of the delimited part …. Fixes #755 --- core/admin/mailu/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index a3fc15a4..2b70e408 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -260,10 +260,19 @@ class Email(object): @classmethod def resolve_destination(cls, localpart, domain_name, ignore_forward_keep=False): + localpart_stripped = None + if os.environ.get('RECIPIENT_DELIMITER') in localpart: + localpart_stripped = localpart.rsplit(os.environ.get('RECIPIENT_DELIMITER'), 1)[0] + alias = Alias.resolve(localpart, domain_name) + if not alias and localpart_stripped: + alias = Alias.resolve(localpart_stripped, domain_name) if alias: return alias.destination + user = User.query.get('{}@{}'.format(localpart, domain_name)) + if not user and localpart_stripped: + user = User.query.get('{}@{}'.format(localpart_stripped, domain_name)) if user: if user.forward_enabled: destination = user.forward_destination