1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2024-12-21 01:49:22 +02:00

Make DNS lookups fail gracefully.

This commit is contained in:
Sebastian Marsching 2023-10-12 21:47:29 +02:00
parent c4a158ea81
commit d8161e6fe2

View File

@ -24,10 +24,10 @@ else {
} }
if (isset($_GET['emailaddress'])) { if (isset($_GET['emailaddress'])) {
$emailaddress_at = strpos($_GET['emailaddress'], '@'); $emailaddress_at = strpos($_GET['emailaddress'], '@');
if ($emailaddress_at !== FALSE) { if ($emailaddress_at !== FALSE) {
$domain = substr($_GET['emailaddress'], $emailaddress_at + 1); $domain = substr($_GET['emailaddress'], $emailaddress_at + 1);
} }
} }
header('Content-Type: application/xml'); header('Content-Type: application/xml');
@ -56,7 +56,7 @@ header('Content-Type: application/xml');
<?php <?php
$records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record $records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
if (count($records) == 0 || $records[0]['target'] != '') { ?> if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$autodiscover_config['pop3']['server']; ?></hostname> <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$autodiscover_config['pop3']['port']; ?></port> <port><?=$autodiscover_config['pop3']['port']; ?></port>
@ -67,7 +67,7 @@ if (count($records) == 0 || $records[0]['target'] != '') { ?>
<?php } ?> <?php } ?>
<?php <?php
$records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record $records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); // check if POP3 is announced as "not provided" via SRV record
if (count($records) == 0 || $records[0]['target'] != '') { ?> if ($records === FALSE || count($records) == 0 || $records[0]['target'] != '') { ?>
<incomingServer type="pop3"> <incomingServer type="pop3">
<hostname><?=$autodiscover_config['pop3']['server']; ?></hostname> <hostname><?=$autodiscover_config['pop3']['server']; ?></hostname>
<port><?=$autodiscover_config['pop3']['tlsport']; ?></port> <port><?=$autodiscover_config['pop3']['tlsport']; ?></port>