diff --git a/data/web/autodiscover.php b/data/web/autodiscover.php index 819dc7ee..730b729f 100644 --- a/data/web/autodiscover.php +++ b/data/web/autodiscover.php @@ -1,7 +1,7 @@ 'yes', 'autodiscoverType' => 'activesync', 'imap' => array( @@ -19,7 +19,7 @@ $config = array( ) ); -if(file_exists('inc/vars.local.inc.php')) { +if (file_exists('inc/vars.local.inc.php')) { include_once 'inc/vars.local.inc.php'; } @@ -29,17 +29,13 @@ error_reporting(0); $data = trim(file_get_contents("php://input")); -// 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' && - 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 - strpos($_SERVER['HTTP_USER_AGENT'], 'MS Connectivity Analyzer') === FALSE // https://testconnectivity.microsoft.com doesn't support EAS for Outlook - ) { - $config['autodiscoverType'] = 'activesync'; - } +if ($autodiscover_config['useEASforOutlook'] == 'yes' && + preg_match('/(Outlook|Office).+(1[5-9]\.)/', $_SERVER['HTTP_USER_AGENT']) && + strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false) { + $autodiscover_config['autodiscoverType'] = 'activesync'; +} +else { + $autodiscover_config['autodiscoverType'] = 'imap'; } $dsn = "$database_type:host=$database_host;dbname=$database_name"; @@ -56,13 +52,14 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { header('WWW-Authenticate: Basic realm=""'); header('HTTP/1.0 401 Unauthorized'); exit; -} else { +} +else { if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { if ($as === "user") { header("Content-Type: application/xml"); echo ''; - if(!$data) { + if (!$data) { list($usec, $sec) = explode(' ', microtime()); echo ''; echo ''; @@ -74,7 +71,7 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { $discover = new SimpleXMLElement($data); $email = $discover->Request->EMailAddress; - if ($config['autodiscoverType'] == 'imap') { + if ($autodiscover_config['autodiscoverType'] == 'imap') { ?> @@ -85,22 +82,22 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { settings IMAP - - + + off off - + on SMTP - - + + off off - + on on off @@ -121,7 +118,7 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { prepare("SELECT `name` FROM `mailbox` WHERE `username`= :username"); @@ -148,8 +145,8 @@ if (!isset($_SERVER['PHP_AUTH_USER']) OR $as !== "user") { MobileSync - - + + diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php index f2d09c5c..7ee06c3a 100644 --- a/data/web/inc/vars.inc.php +++ b/data/web/inc/vars.inc.php @@ -17,6 +17,28 @@ $database_name = getenv('DBNAME'); // Other variables $mailcow_hostname = getenv('MAILCOW_HOSTNAME'); +// Autodiscover settings +$autodiscover_config = array( + // Enable the autodiscover service for Outlook desktop clients + 'useEASforOutlook' => 'yes', + // General autodiscover service type: "activesync" or "imap" + 'autodiscoverType' => 'activesync', + 'imap' => array( + 'server' => $mailcow_hostname, + 'port' => getenv('IMAPS_PORT'), + 'ssl' => 'on', + ), + 'smtp' => array( + 'server' => $mailcow_hostname, + 'port' => getenv('SMTPS_PORT'), + 'ssl' => 'on' + ), + 'activesync' => array( + 'url' => 'https://'.$mailcow_hostname.'/Microsoft-Server-ActiveSync' + ) +); + + // Where to go after adding and editing objects // Can be "form" or "previous" // "form" will stay in the current form, "previous" will redirect to previous page diff --git a/docker-compose.yml b/docker-compose.yml index 2c9f6666..ad092f1c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -122,6 +122,14 @@ services: - DBUSER=${DBUSER} - DBPASS=${DBPASS} - MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME} + - IMAP_PORT=${IMAP_PORT:-143} + - IMAPS_PORT=${IMAPS_PORT:-993} + - POP_PORT=${POP_PORT:-110} + - POPS_PORT=${POPS_PORT:-995} + - SIEVE_PORT=${SIEVE_PORT:-4190} + - SUBMISSION_PORT=${SUBMISSION_PORT:-587} + - SMTPS_PORT=${SMTPS_PORT:-465} + - SMTP_PORT=${SMTP_PORT:-25} restart: always logging: options: