From ccd2cad4f1b2dc5caf9d679f27975e885ea65f4e Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Thu, 10 Mar 2022 10:00:51 +0100 Subject: [PATCH] Autodiscovery microsoft style --- core/admin/mailu/internal/views/autoconfig.py | 36 +++++++++++++++++-- core/nginx/conf/nginx.conf | 10 ++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/core/admin/mailu/internal/views/autoconfig.py b/core/admin/mailu/internal/views/autoconfig.py index 3538e756..b93794b3 100644 --- a/core/admin/mailu/internal/views/autoconfig.py +++ b/core/admin/mailu/internal/views/autoconfig.py @@ -37,6 +37,38 @@ def autoconfig_mozilla(): Configure your email client -\r\n -''' +\r\n''' + return flask.Response(xml, mimetype='text/xml', status=200) + +@internal.route("/autoconfig/microsoft") +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'] + xml = f''' + + + +email +settings + +IMAP +{hostname} +993 +on +off +on +on + + +SMTP +{hostname} +465 +on +off +on +on + + + +\r\n''' return flask.Response(xml, mimetype='text/xml', status=200) diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index 6d416c16..87775f80 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -121,8 +121,14 @@ http { add_header Referrer-Policy 'same-origin'; # mozilla autoconfiguration - location ^~ /.well-known/autoconfig/mail/config-v1.1.xml { - rewrite /.well-known/autoconfig/mail/config-v1.1.xml /internal/autoconfig/mozilla break; + location ~ ^/(\.well\-known/autoconfig/)?mail/config\-v1\.1\.xml { + rewrite ^ /internal/autoconfig/mozilla break; + include /etc/nginx/proxy.conf; + proxy_pass http://$admin; + } + # microsoft autoconfiguration + location ~* ^/Autodiscover/Autodiscover.xml { + rewrite ^ /internal/autoconfig/microsoft break; include /etc/nginx/proxy.conf; proxy_pass http://$admin; }