diff --git a/data/web/autoconfig.php b/data/web/autoconfig.php
index 901a245d6..5520f2efd 100644
--- a/data/web/autoconfig.php
+++ b/data/web/autoconfig.php
@@ -30,6 +30,40 @@ if (isset($_GET['emailaddress'])) {
}
}
+function autoconfig_service_enabled($_service_type) {
+ global $autodiscover_config;
+ global $domain;
+ $_disabled = FALSE;
+ switch ($_service_type) {
+ // TODO Check autodiscover_config
+ case 'imap':
+ $_disabled = isset($autodiscover_config['imap']['tlsportDisabled']) && $autodiscover_config['imap']['tlsportDisabled'] === TRUE;
+ break;
+ case 'imaps':
+ $_disabled = isset($autodiscover_config['imap']['portDisabled']) && $autodiscover_config['imap']['portDisabled'] === TRUE;
+ break;
+ case 'pop3':
+ $_disabled = isset($autodiscover_config['pop3']['tlsportDisabled']) && $autodiscover_config['pop3']['tlsportDisabled'] === TRUE;
+ break;
+ case 'pop3s':
+ $_disabled = isset($autodiscover_config['pop3']['portDisabled']) && $autodiscover_config['pop3']['portDisabled'] === TRUE;
+ break;
+ case 'smtps':
+ $_disabled = isset($autodiscover_config['smtp']['portDisabled']) && $autodiscover_config['smtp']['portDisabled'] === TRUE;
+ break;
+ case 'submission':
+ $_disabled = isset($autodiscover_config['smtp']['tlsportDisabled']) && $autodiscover_config['smtp']['tlsportDisabled'] === TRUE;
+ break;
+ }
+ // If the port is disabled in the config, do not even bother to check the DNS records.
+ if ($_disabled === TRUE) {
+ return FALSE;
+ }
+ // Check whether the service is announced as "not provided" via a SRV record.
+ $_records = dns_get_record('_' . $_service_type .'._tcp.' . $domain, DNS_SRV);
+ return $_records === FALSE || count($_records) == 0 || $_records[0]['target'] != '';
+}
+
header('Content-Type: application/xml');
?>
= ''; ?>
@@ -39,6 +73,8 @@ header('Content-Type: application/xml');
A mailcow mail server
mail server
+
=$autodiscover_config['imap']['server']; ?>
=$autodiscover_config['imap']['port']; ?>
@@ -46,6 +82,9 @@ header('Content-Type: application/xml');
%EMAILADDRESS%
password-cleartext
+
+
=$autodiscover_config['imap']['server']; ?>
=$autodiscover_config['imap']['tlsport']; ?>
@@ -53,10 +92,10 @@ header('Content-Type: application/xml');
%EMAILADDRESS%
password-cleartext
+
+if (autoconfig_service_enabled('pop3s')) { ?>
=$autodiscover_config['pop3']['server']; ?>
=$autodiscover_config['pop3']['port']; ?>
@@ -66,8 +105,7 @@ if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') {
+if (autoconfig_service_enabled('pop3')) { ?>
=$autodiscover_config['pop3']['server']; ?>
=$autodiscover_config['pop3']['tlsport']; ?>
@@ -77,6 +115,8 @@ if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') {
+
=$autodiscover_config['smtp']['server']; ?>
=$autodiscover_config['smtp']['port']; ?>
@@ -84,6 +124,9 @@ if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') {
%EMAILADDRESS%
password-cleartext
+
+
=$autodiscover_config['smtp']['server']; ?>
=$autodiscover_config['smtp']['tlsport']; ?>
@@ -91,6 +134,7 @@ if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') {
%EMAILADDRESS%
password-cleartext
+
If you didn't change the password given to you by the administrator or if you didn't change it in a long time, please consider doing that now.
diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php
index 392b0d49e..7c05ab0a2 100644
--- a/data/web/inc/vars.inc.php
+++ b/data/web/inc/vars.inc.php
@@ -43,6 +43,9 @@ $autodiscover_config = array(
// Please don't use STARTTLS-enabled service ports in the "port" variable.
// The autodiscover service will always point to SMTPS and IMAPS (TLS-wrapped services).
// The autoconfig service will additionally announce the STARTTLS-enabled ports, specified in the "tlsport" variable.
+ // In order to disable one of the ports from being presented in the autodiscovery procss, set portDisabled or tlsPortDisabled to true.
+ // For example, in vars.local.inc.php add:
+ // $autodiscover_config['pop3']['tlsportDisabled'] = true;
'imap' => array(
'server' => $mailcow_hostname,
'port' => (int)filter_var(substr(getenv('IMAPS_PORT'), strrpos(getenv('IMAPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
diff --git a/data/web/mobileconfig.php b/data/web/mobileconfig.php
index 44aaa30ae..8ffd8893c 100644
--- a/data/web/mobileconfig.php
+++ b/data/web/mobileconfig.php
@@ -68,6 +68,24 @@ if (isset($_GET['app_password'])) {
$app_password = false;
}
+if (isset($autodiscover_config['imap']['portDisabled'])
+ && $autodiscover_config['imap']['portDisabled'] === TRUE
+ && !isset($autodiscover_config['imap']['tlsportDisabled'])
+ || $autodiscover_config['imap']['tlsportDisabled'] !== TRUE) {
+ $imap_port = $autodiscover_config['imap']['tlsport'];
+} else {
+ $imap_port = $autodiscover_config['imap']['port'];
+}
+
+if (isset($autodiscover_config['smtp']['portDisabled'])
+ && $autodiscover_config['smtp']['portDisabled'] === TRUE
+ && !isset($autodiscover_config['smtp']['tlsportDisabled'])
+ || $autodiscover_config['smtp']['tlsportDisabled'] !== TRUE) {
+ $smtp_port = $autodiscover_config['smtp']['tlsport'];
+} else {
+ $smtp_port = $autodiscover_config['smtp']['port'];
+}
+
echo '' . "\n";
?>
@@ -89,7 +107,7 @@ echo '' . "\n";
IncomingMailServerHostName
=$autodiscover_config['imap']['server']?>
IncomingMailServerPortNumber
- =$autodiscover_config['imap']['port']?>
+ =$imap_port?>
IncomingMailServerUseSSL
IncomingMailServerUsername
@@ -103,7 +121,7 @@ echo '' . "\n";
OutgoingMailServerHostName
=$autodiscover_config['smtp']['server']?>
OutgoingMailServerPortNumber
- =$autodiscover_config['smtp']['port']?>
+ =$smtp_port?>
OutgoingMailServerUseSSL
OutgoingMailServerUsername