From 3aeb4f8c042d18dd68dd5689d89642afa8684368 Mon Sep 17 00:00:00 2001 From: Alexander-Ger-Reich <50119493+Alexander-Ger-Reich@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:24:54 +0200 Subject: [PATCH] Update autodiscover-json.php Not pretty, but it works. This ensures that you can add a user account in Outlook Desktop again using the normal setup. Enter your email address, select IMAP, enter your password, and you're done. This is intended as a suggestion. And is intended to encourage discussion. Signed-off-by: Alexander-Ger-Reich <50119493+Alexander-Ger-Reich@users.noreply.github.com> --- data/web/autodiscover-json.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/data/web/autodiscover-json.php b/data/web/autodiscover-json.php index 2fa96990e..6662166ee 100644 --- a/data/web/autodiscover-json.php +++ b/data/web/autodiscover-json.php @@ -8,12 +8,15 @@ if(file_exists('inc/vars.local.inc.php')) { $autodiscover_config = array_merge($default_autodiscover_config, $autodiscover_config); header('Content-type: application/json'); -if (strtolower($_GET['Protocol']) == 'activesync' && getenv('SKIP_SOGO') != "y") { - echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config['activesync']['url'] . '"}'; -} -elseif (strtolower($_GET['Protocol']) == 'autodiscoverv1') { +if (strtolower($_GET['Protocol']) == 'autodiscoverv1') { echo '{"Protocol":"AutodiscoverV1","Url":"https://' . $_SERVER['HTTP_HOST'] . '/Autodiscover/Autodiscover.xml"}'; } +elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'Autodetect') !== false) { + http_response_code(404); +} +elseif (strtolower($_GET['Protocol']) == 'activesync' && getenv('SKIP_SOGO') != "y") { + echo '{"Protocol":"ActiveSync","Url":"' . $autodiscover_config['activesync']['url'] . '"}'; +} else { http_response_code(400); echo '{"ErrorCode":"InvalidProtocol","ErrorMessage":"The given protocol value \u0027' . preg_replace("/[^\da-z]/i", '', $_GET['Protocol']) . '\u0027 is invalid. Supported values are \u0027ActiveSync,AutodiscoverV1\u0027"}';