autodiscover-json.php ignores $autodiscover_config['autodiscoverType'], so new Outlook fails even when admins chose IMAP

Author: gunnie-agencyCreated Sep 24, 2026Updated Sep 24, 2026
Labelsbug

Contribution guidelines

Checklist prior issue creation

  • I understand that failure to follow below instructions may cause this issue to be closed.
  • I understand that vague, incomplete or inaccurate information may cause this issue to be closed.
  • I understand that this form is intended solely for reporting software bugs and not for support-related inquiries.
  • I understand that all responses are voluntary and community-driven, and do not constitute commercial support.
  • I confirm that I have reviewed previous issues to ensure this matter has not already been addressed.
  • I confirm that my environment meets all prerequisite requirements as specified in the official documentation.

Description

data/web/autodiscover.php respects $autodiscover_config['autodiscoverType']: with 'imap' the XML autodiscover returns IMAP/SMTP. data/web/autodiscover-json.php does not. For ?Protocol=ActiveSync it returns the ActiveSync URL whenever SKIP_SOGO != "y", regardless of autodiscoverType.

The new Outlook for Windows (via Microsoft's cloud-side account setup) queries /autodiscover/autodiscover.json/v1.0/<user>?Protocol=ActiveSync first, even when the user explicitly picks IMAP. It follows the ActiveSync URL, fails, and shows a misleading error ("Your email provider can no longer connect to Outlook ... looks like a shared mailbox") instead of falling back to IMAP, while the user's IMAP logins succeed at the same moment.

The docs already state that ActiveSync does not work with newer Outlook versions. The problem is that admins who set autodiscoverType => 'imap' to avoid exactly that still get a broken setup, because the JSON endpoint ignores the setting.

Suggested fix: in autodiscover-json.php, only return ActiveSync when $autodiscover_config['autodiscoverType'] === 'activesync' (and SOGo is enabled); otherwise answer 400 InvalidProtocol, as the file already does for unknown protocols.

Workaround for others hitting this: an nginx site.*.custom with location ^~ /autodiscover/autodiscover.json (plus the capitalised variant) that returns 400 for $arg_protocol ~* ^activesync$ and passes everything else to autodiscover-json.php. ^~ is needed because site.*.custom is included after mailcow's own regex location.

Steps to reproduce:

  1. Set $autodiscover_config['autodiscoverType'] = 'imap'; in data/web/inc/vars.local.inc.php (SOGo enabled).
  2. GET https://autodiscover.example.com/autodiscover/autodiscover.json/v1.0/[email protected]?Protocol=ActiveSync
  3. Expected: HTTP 400 {"ErrorCode":"InvalidProtocol",...}, so clients fall back to AutodiscoverV1 / IMAP.
  4. Actual: {"Protocol":"ActiveSync","Url":"https://mail.example.com/Microsoft-Server-ActiveSync"}
  5. Add the account in the new Outlook for Windows (even via Advanced setup > IMAP): it shows the "can no longer connect ... shared mailbox" error.

Logs:

plain
nginx-mailcow-1 | 52.125.141.22 - - "GET /autodiscover/autodiscover.json/v1.0/[email protected]?Protocol=ActiveSync&RedirectCount=1 HTTP/1.1" 200
nginx-mailcow-1 | 52.125.141.22 - - "OPTIONS /Microsoft-Server-ActiveSync HTTP/1.1" 401
nginx-mailcow-1 | 52.125.141.22 - - "OPTIONS /Microsoft-Server-ActiveSync HTTP/1.1" 401
dovecot-mailcow-1 | imap-login: Login: user=<[email protected]>, method=PLAIN (same user, same minutes: IMAP itself works)

Which branch are you using?

master (stable)

Which architecture are you using?

x86_64

Operating System:

Ubuntu 24.04.5 LTS

Server/VM specifications:

124 GB RAM, 32 CPU cores (dedicated server)

Is Apparmor, SELinux or similar active?

yes (AppArmor, Ubuntu default)

Virtualization technology:

none (bare metal)

Docker version:

29.8.1

docker-compose version or docker compose version:

5.5.1

mailcow version:

2026-09

Reverse proxy:

none

Logs of git diff:

plain
Local tuning in data/conf/dovecot/conf.d/fts.conf and data/conf/postfix/main.cf, unrelated to autodiscover. Plus data/web/inc/vars.local.inc.php (autodiscoverType = imap) and the nginx site.*.custom workaround described above.

Logs of iptables -L -vn:

plain
Not applicable: this is an application-level issue in data/web/autodiscover-json.php, with no firewall involvement. Happy to provide on request.

Logs of ip6tables -L -vn:

plain
Not applicable: this is an application-level issue in data/web/autodiscover-json.php, with no firewall involvement. Happy to provide on request.

Logs of iptables -L -vn -t nat:

plain
Not applicable: this is an application-level issue in data/web/autodiscover-json.php, with no firewall involvement. Happy to provide on request.

Logs of ip6tables -L -vn -t nat:

plain
Not applicable: this is an application-level issue in data/web/autodiscover-json.php, with no firewall involvement. Happy to provide on request.

DNS check:

plain
198.252.206.1

Source: mailcow/mailcow-dockerized