1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-12 10:45:38 +02:00

Merge pull request #778 from Nebukadneza/fix_recipient_delimiter

Attempt stripping recipient delimiter from localpart
This commit is contained in:
mergify[bot] 2019-01-07 19:01:44 +00:00 committed by GitHub
commit 3b5f3af207
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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