Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

autodiscover

A single Go binary that replaces an nginx + PHP stack for serving email autodiscover responses. It reads a settings.json file and generates XML responses on the fly for multiple protocols and clients.

Supported Protocols and Clients

Protocol / ClientEndpointFormat
Microsoft Outlook (POX Autodiscover)POST /autodiscover/autodiscover.xmlPOX XML
Microsoft Exchange ActiveSyncPOST /autodiscover/autodiscover.xmlMobileSync XML
Thunderbird / MozillaGET /mail/config-v1.1.xmlclientConfig XML
Apple iOS / macOSGET /profile.mobileconfigProperty List (.plist)
CalDAV (RFC 6764)GET /.well-known/caldavHTTP redirect
CardDAV (RFC 6764)GET /.well-known/carddavHTTP redirect
Matrix federation delegationGET /.well-known/matrix/serverJSON (spec)
Matrix homeserver discoveryGET /.well-known/matrix/clientJSON (spec)

Building

You’ll need Go 1.23 or later.

To build for the current machine just do make build. To build for other architectures do something like make build-linux.

Running

./build/autodiscover-linux-amd64 -addr :8080 -config /path/to/settings.json
FlagDefaultDescription
-addr:8080TCP address to listen on
-configsettings.jsonPath to the JSON configuration file

Configuration (settings.json)

See example-settings.json for a complete example.

Top-level structure

FieldTypeRequiredDescription
infoobjectyesGeneral provider information
serverobjectyesIMAP and SMTP server settings
ttlintegernoTime-to-live in hours for cached settings. Defaults to 1
matrixobjectnoMatrix well-known delegation targets
caldavobjectnoCalDAV server configuration
carddavobjectnoCardDAV server configuration
exchangeobjectnoMicrosoft Exchange Web Services URLs
activesyncobjectnoExchange ActiveSync endpoint URL
vpnobjectnoVPN configuration for Apple profiles
mdmobjectnoMobile Device Management enrollment URL

info

FieldTypeDescription
namestringHuman-readable provider name
urlstringSupport or home page URL
domainstringPrimary mail domain

server.imap and server.smtp

FieldTypeDescription
hoststringServer hostname or IP address
portintegerTCP port number
socketstringEncryption method: "SSL", "STARTTLS", or "plain"

server.domain_required

FieldTypeDescription
domain_requiredbooleanWhether the authentication domain is required

caldav and carddav

FieldTypeDescription
hoststringDAV server hostname
portintegerTCP port number
sslbooleanWhether to use HTTPS
principal_urlstringUser-specific principal path. Supports placeholders %EMAILADDRESS%, %EMAILLOCALPART%, %EMAILDOMAIN%

matrix

Optional. When absent, both matrix endpoints return 404 with a plain-text explanation (which triggers SRV-based federation fallback).

FieldTypeDescription
serverstringValue for m.server — the target homeserver hostname (or host:port) federation uses
homeserverstringValue for m.homeserver.base_url, e.g. https://matrix.example.com
identity_serverstringOptional override for m.identity_server.base_url, defaults to homeserver

exchange

FieldTypeDescription
ews_urlstringExchange Web Services URL
oab_urlstringOffline Address Book URL
oof_urlstringOut of Office URL

activesync

FieldTypeDescription
urlstringActiveSync endpoint (e.g. https://mail.example.com/Microsoft-Server-ActiveSync)

vpn

FieldTypeDescription
typestringVPN type: "IKEv2", "L2TP", "PPTP", "IPSec", etc.
hoststringVPN server hostname
remote_idstringRemote identifier (e.g. for IKEv2)
local_idstringLocal identifier (e.g. for IKEv2)
auth_methodstringAuthentication method: "None", "Certificate", "SharedSecret", "Password"

mdm

FieldTypeDescription
server_urlstringMDM enrollment server URL

Placeholders

The following placeholders are expanded in URLs where noted above:

PlaceholderExpands to
%EMAILADDRESS%Full email address, e.g. user@example.com
%EMAILLOCALPART%Local part, e.g. user
%EMAILDOMAIN%Domain part, e.g. example.com

Apple Configuration Profile (/profile.mobileconfig)

When ?email=user@example.com is provided, the generated .mobileconfig includes payloads for all configured services:

  • Email (com.apple.mail.managed) — IMAP incoming, SMTP outgoing
  • CalDAV (com.apple.caldav.account)
  • CardDAV (com.apple.carddav.account)
  • VPN (com.apple.vpn.managed)
  • MDM (com.apple.mdm)

Payload UUIDs are deterministically derived from the domain and payload type so they remain stable across restarts.

Well-known Redirects

The server responds to RFC 6764 .well-known requests with HTTP redirects to the configured DAV principal URLs:

RequestRedirect
GET /.well-known/caldav?email=user@example.com307 = to expanded CalDAV principal URL
GET /.well-known/carddav?email=user@example.com307 = to expanded CalDAV principal URL
GET /.well-known/matrix/server200 = JSON with m.server
GET /.well-known/matrix/client200 = JSON with homeserver/identity URLs

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages