Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simplified version of https://github.com/mailcow/mailcow-dockerized/blob/master/data/web/autodiscover-json.php for anyone wanting to to support email autodiscovery like at https://github.com/gronke/email-autodiscover . Keywords: GET /autodiscover/autodiscover.json?Email=user%40domain.com&Protocol=ActiveSync&RedirectCount=1
<?php
header("Content-Type: application/json");
if ($_GET['Protocol'] == 'ActiveSync') {
echo '{"Protocol":"ActiveSync","Url":"https://' . $_SERVER['HTTP_HOST'] . '/Microsoft-Server-ActiveSync"}';
}
elseif ($_GET['Protocol'] == 'AutodiscoverV1') {
echo '{"Protocol":"AutodiscoverV1","Url":"https://' . $_SERVER['HTTP_HOST'] . '/Autodiscover/Autodiscover.xml"}';
}
else {
http_response_code(400);
echo '{"ErrorCode":"InvalidProtocol","ErrorMessage":"The given protocol value \u0027' . $_GET['Protocol'] . '\u0027 is invalid. Supported values are \u0027ActiveSync,AutodiscoverV1\u0027"}';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.