From 646957efee565952739780c91184d08562bdfc57 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 18 Jun 2017 10:08:19 +0200 Subject: [PATCH 1/4] Autodiscovery for eM Client It can be identified by its lack of user agent header. Through additional Protocol tags, it can also have CalDAV and CardDAV configured. --- data/web/autodiscover.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index 3f2fd1b4..c0a06e87 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -33,6 +33,10 @@ if ($config['useEASforOutlook'] == 'no') { } } +if (!isset($_SERVER['HTTP_USER_AGENT']) || empty($_SERVER['HTTP_USER_AGENT'])) { // eM Client sends no user agent + $config['autodiscoverType'] = 'imap'; +} + $dsn = "$database_type:host=$database_host;dbname=$database_name"; $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, @@ -94,6 +98,18 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { on off + + CalDAV + https:///SOGo/dav//Calendar + off + + + + CardDAV + https:///SOGo/dav//Contacts + off + + Date: Sun, 18 Jun 2017 13:09:28 +0200 Subject: [PATCH 2/4] Autodiscovery for arbitrary clients. EAS only for Outlook 2013+ Mobile and Desktop clients can be differentiated based on the response scheme they request. Mobile clients and Outlook 2013+ get EAS, others get IMAP --- data/web/autodiscover.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index c0a06e87..fdef02a5 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -27,14 +27,18 @@ if(file_exists('inc/vars.local.inc.php')) { error_reporting(0); -if ($config['useEASforOutlook'] == 'no') { - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Outlook')) { - $config['autodiscoverType'] = 'imap'; - } -} +$data = trim(file_get_contents("php://input")); -if (!isset($_SERVER['HTTP_USER_AGENT']) || empty($_SERVER['HTTP_USER_AGENT'])) { // eM Client sends no user agent +// Desktop clients need IMAP, unless it's Outlook 2013 or higher on Windows +if (strpos($data, 'autodiscover/outlook/responseschema')) { // desktop client $config['autodiscoverType'] = 'imap'; + if ($config['useEASforOutlook'] == 'yes' && + strpos($_SERVER['HTTP_USER_AGENT'], 'Outlook') !== FALSE && // Outlook + strpos($_SERVER['HTTP_USER_AGENT'], 'Windows NT') !== FALSE && // Windows + preg_match('/Outlook (1[5-9]\.|[2-9]|1[0-9][0-9])/', $_SERVER['HTTP_USER_AGENT']) // Outlook 2013 (version 15) or higher + ) { + $config['autodiscoverType'] = 'activesync'; + } } $dsn = "$database_type:host=$database_host;dbname=$database_name"; @@ -57,7 +61,6 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { header("Content-Type: application/xml"); echo ''; - $data = trim(file_get_contents("php://input")); if(!$data) { list($usec, $sec) = explode(' ', microtime()); echo ''; From 4a379d05407d8450940f31686814a0dd1e8b6282 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 18 Jun 2017 14:36:27 +0200 Subject: [PATCH 3/4] Satisfy Microsoft Remote Connectivity Analyzer --- data/web/autodiscover.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index fdef02a5..422f8426 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -35,7 +35,8 @@ if (strpos($data, 'autodiscover/outlook/responseschema')) { // desktop client if ($config['useEASforOutlook'] == 'yes' && strpos($_SERVER['HTTP_USER_AGENT'], 'Outlook') !== FALSE && // Outlook strpos($_SERVER['HTTP_USER_AGENT'], 'Windows NT') !== FALSE && // Windows - preg_match('/Outlook (1[5-9]\.|[2-9]|1[0-9][0-9])/', $_SERVER['HTTP_USER_AGENT']) // Outlook 2013 (version 15) or higher + preg_match('/Outlook (1[5-9]\.|[2-9]|1[0-9][0-9])/', $_SERVER['HTTP_USER_AGENT']) && // Outlook 2013 (version 15) or higher + strpos($_SERVER['HTTP_USER_AGENT'], 'MS Connectivity Analyzer') === FALSE // https://testconnectivity.microsoft.com doesn't support EAS for Outlook ) { $config['autodiscoverType'] = 'activesync'; } From 08506f7c81e14822824c4dcf15fc800ef26ad0b0 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 18 Jun 2017 16:07:14 +0200 Subject: [PATCH 4/4] Autodiscovery: send display name to IMAP client --- data/web/autodiscover.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index 422f8426..819dc7ee 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -29,7 +29,7 @@ error_reporting(0); $data = trim(file_get_contents("php://input")); -// Desktop clients need IMAP, unless it's Outlook 2013 or higher on Windows +// Desktop client needs IMAP, unless it's Outlook 2013 or higher on Windows if (strpos($data, 'autodiscover/outlook/responseschema')) { // desktop client $config['autodiscoverType'] = 'imap'; if ($config['useEASforOutlook'] == 'yes' && @@ -77,6 +77,9 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { if ($config['autodiscoverType'] == 'imap') { ?> + + + email settings