mirror of
https://github.com/Mailu/Mailu.git
synced 2024-12-12 10:45:38 +02:00
Reflect the data from the POST
This commit is contained in:
parent
14931c4acd
commit
3e6f3a95a4
@ -2,6 +2,7 @@ from mailu.internal import internal
|
||||
|
||||
from flask import current_app as app
|
||||
import flask
|
||||
import xmltodict
|
||||
|
||||
@internal.route("/autoconfig/mozilla")
|
||||
def autoconfig_mozilla():
|
||||
@ -50,13 +51,20 @@ def autoconfig_microsoft_json():
|
||||
else:
|
||||
return flask.abort(404)
|
||||
|
||||
@internal.route("/autoconfig/microsoft", methods=['GET', 'POST'])
|
||||
@internal.route("/autoconfig/microsoft", methods=['POST'])
|
||||
def autoconfig_microsoft():
|
||||
# https://docs.microsoft.com/en-us/previous-versions/office/office-2010/cc511507(v=office.14)?redirectedfrom=MSDN#Anchor_3
|
||||
hostname = app.config['HOSTNAME']
|
||||
try:
|
||||
xmlRequest = (flask.request.data).decode("utf-8")
|
||||
xml = xmltodict.parse(xmlRequest[xmlRequest.find('<'):xmlRequest.rfind('>')+1])
|
||||
schema = xml['Autodiscover']['Request']['AcceptableResponseSchema']
|
||||
if schema != 'http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a':
|
||||
return flask.abort(404)
|
||||
email = xml['Autodiscover']['Request']['EMailAddress']
|
||||
xml = f'''<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
||||
<Autodiscover xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006\">
|
||||
<Response xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a\">
|
||||
<Autodiscover xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006\">
|
||||
<Response xmlns="{schema}">
|
||||
<Account>
|
||||
<AccountType>email</AccountType>
|
||||
<Action>settings</Action>
|
||||
@ -64,22 +72,27 @@ def autoconfig_microsoft():
|
||||
<Type>IMAP</Type>
|
||||
<Server>{hostname}</Server>
|
||||
<Port>993</Port>
|
||||
<LoginName>{email}</LoginName>
|
||||
<DomainRequired>on</DomainRequired>
|
||||
<SPA>off</SPA>
|
||||
<Encryption>TLS</Encryption>
|
||||
<SSL>on</SSL>
|
||||
</Protocol>
|
||||
<Protocol>
|
||||
<Type>SMTP</Type>
|
||||
<Server>{hostname}</Server>
|
||||
<Port>465</Port>
|
||||
<LoginName>{email}</LoginName>
|
||||
<DomainRequired>on</DomainRequired>
|
||||
<SPA>off</SPA>
|
||||
<Encryption>TLS</Encryption>
|
||||
<SSL>on</SSL>
|
||||
</Protocol>
|
||||
</Account>
|
||||
</Response>
|
||||
</Autodiscover>'''
|
||||
</Autodiscover>'''
|
||||
return flask.Response(xml, mimetype='text/xml', status=200)
|
||||
except:
|
||||
pass
|
||||
return flask.abort(400)
|
||||
|
||||
@internal.route("/autoconfig/apple")
|
||||
def autoconfig_apple():
|
||||
|
@ -73,3 +73,4 @@ webencodings==0.5.1
|
||||
Werkzeug==2.0.2
|
||||
WTForms==2.3.3
|
||||
WTForms-Components==0.10.5
|
||||
xmltodict==0.12.0
|
||||
|
@ -25,3 +25,4 @@ srslib
|
||||
marshmallow
|
||||
flask-marshmallow
|
||||
marshmallow-sqlalchemy
|
||||
xmltodict
|
||||
|
Loading…
Reference in New Issue
Block a user