Skip to content

aardsoft/autodiscover

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

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
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%

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors