1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-03-03 14:52:36 +02:00

ghostwheel42's suggestion

This commit is contained in:
Florent Daigniere 2022-03-07 09:09:36 +01:00
parent d723326b8e
commit cd3eee4c51

View File

@ -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 '<MAILER-DAEMON>' instead of '<>'; so let's
# consider void any such thing.
return '@' not in email