|
|
@ -20,37 +20,34 @@ def postfix_mailbox_map(email):
|
|
|
|
|
|
|
|
|
|
|
|
@internal.route("/postfix/alias/<alias>")
|
|
|
|
@internal.route("/postfix/alias/<alias>")
|
|
|
|
def postfix_alias_map(alias):
|
|
|
|
def postfix_alias_map(alias):
|
|
|
|
localpart, domain = alias.split('@', 1) if '@' in alias else (None, alias)
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(alias)
|
|
|
|
alternative = models.Alternative.query.get(domain)
|
|
|
|
|
|
|
|
if alternative:
|
|
|
|
|
|
|
|
domain = alternative.domain_name
|
|
|
|
|
|
|
|
email = '{}@{}'.format(localpart, domain)
|
|
|
|
|
|
|
|
if localpart is None:
|
|
|
|
if localpart is None:
|
|
|
|
return flask.jsonify(domain)
|
|
|
|
return flask.jsonify(domain_name)
|
|
|
|
else:
|
|
|
|
destination = models.Email.resolve_destination(localpart, domain_name)
|
|
|
|
alias_obj = models.Alias.resolve(localpart, domain)
|
|
|
|
return flask.jsonify(",".join(destination)) if destination else flask.abort(404)
|
|
|
|
if alias_obj:
|
|
|
|
|
|
|
|
return flask.jsonify(",".join(alias_obj.destination))
|
|
|
|
|
|
|
|
user_obj = models.User.query.get(email)
|
|
|
|
|
|
|
|
if user_obj:
|
|
|
|
|
|
|
|
return flask.jsonify(user_obj.destination)
|
|
|
|
|
|
|
|
return flask.abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@internal.route("/postfix/transport/<email>")
|
|
|
|
@internal.route("/postfix/transport/<email>")
|
|
|
|
def postfix_transport(email):
|
|
|
|
def postfix_transport(email):
|
|
|
|
localpart, domain = email.split('@', 1) if '@' in email else (None, email)
|
|
|
|
if email == '*':
|
|
|
|
relay = models.Relay.query.get(domain) or flask.abort(404)
|
|
|
|
return flask.abort(404)
|
|
|
|
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(email)
|
|
|
|
|
|
|
|
relay = models.Relay.query.get(domain_name) or flask.abort(404)
|
|
|
|
return flask.jsonify("smtp:[{}]".format(relay.smtp))
|
|
|
|
return flask.jsonify("smtp:[{}]".format(relay.smtp))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@internal.route("/postfix/sender/<sender>")
|
|
|
|
@internal.route("/postfix/sender/login/<sender>")
|
|
|
|
def postfix_sender(sender):
|
|
|
|
def postfix_sender_login(sender):
|
|
|
|
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(sender)
|
|
|
|
|
|
|
|
if localpart is None:
|
|
|
|
|
|
|
|
return flask.abort(404)
|
|
|
|
|
|
|
|
destination = models.Email.resolve_destination(localpart, domain_name, True)
|
|
|
|
|
|
|
|
return flask.jsonify(",".join(destination)) if destination else flask.abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@internal.route("/postfix/sender/access/<sender>")
|
|
|
|
|
|
|
|
def postfix_sender_access(sender):
|
|
|
|
""" Simply reject any sender that pretends to be from a local domain
|
|
|
|
""" Simply reject any sender that pretends to be from a local domain
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
localpart, domain_name = sender.split('@', 1) if '@' in sender else (None, sender)
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(sender)
|
|
|
|
domain = models.Domain.query.get(domain_name)
|
|
|
|
return flask.jsonify("REJECT") if models.Domain.query.get(domain_name) else flask.abort(404)
|
|
|
|
alternative = models.Alternative.query.get(domain_name)
|
|
|
|
|
|
|
|
if domain or alternative:
|
|
|
|
|
|
|
|
return flask.jsonify("REJECT")
|
|
|
|
|
|
|
|
return flask.abort(404)
|
|
|
|
|
|
|
|