From cd3eee4c51855de4de2033b0b0a45dfe035c0f50 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Mon, 7 Mar 2022 09:09:36 +0100 Subject: [PATCH] ghostwheel42's suggestion --- core/admin/mailu/internal/views/postfix.py | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/core/admin/mailu/internal/views/postfix.py b/core/admin/mailu/internal/views/postfix.py index 909b776e..591dbaf3 100644 --- a/core/admin/mailu/internal/views/postfix.py +++ b/core/admin/mailu/internal/views/postfix.py @@ -159,20 +159,13 @@ def postfix_sender_rate(sender): def postfix_sender_access(sender): """ Simply reject any sender that pretends to be from a local domain """ - try: - if not is_void_address(sender): + if '@' in email: + if email.startswith('<') and email.endswith('>'): + email = email[1:-1] + try: localpart, domain_name = models.Email.resolve_domain(sender) - return flask.jsonify("REJECT") if models.Domain.query.get(domain_name) else flask.abort(404) - except sqlalchemy.exc.StatementError: - pass + if models.Domain.query.get(domain_name): + return flask.jsonify("REJECT") + except sqlalchemy.exc.StatementError: + pass return flask.abort(404) - - -def is_void_address(email): - '''True if the email is void (null) email address. - ''' - if email.startswith('<') and email.endswith('>'): - email = email[1:-1] - # Some MTAs use things like '' instead of '<>'; so let's - # consider void any such thing. - return '@' not in email