Solve hang on setup page when the dns_get_record call is blocked by the

firewall.
This commit is contained in:
ldestailleur
2025-08-08 23:11:56 +02:00
parent a0b3a9b0da
commit 53ee283828
2 changed files with 28 additions and 22 deletions

View File

@@ -1119,34 +1119,39 @@ if ($action == 'edit') {
}
// Test DNS entry for emails
foreach (array('SPF', 'DMARC') as $dnstype) {
foreach ($domainstotest as $domaintotest => $listofemails) {
$dnsinfo = false;
$foundforemail = 0;
if (!empty($domaintotest) && function_exists('dns_get_record') && !getDolGlobalString('MAIN_DISABLE_DNS_GET_RECORD')) {
$domain = $domaintotest;
if ($dnstype == 'DMARC') {
$domain = '_dmarc.'.$domain;
if ($action == 'testsetup') {
foreach (array('SPF', 'DMARC') as $dnstype) {
foreach ($domainstotest as $domaintotest => $listofemails) {
$dnsinfo = false;
$foundforemail = 0;
if (!empty($domaintotest) && function_exists('dns_get_record') && !getDolGlobalString('MAIN_DISABLE_DNS_GET_RECORD')) {
$domain = $domaintotest;
if ($dnstype == 'DMARC') {
$domain = '_dmarc.'.$domain;
}
$dnsinfo = dns_get_record($domain, DNS_TXT);
}
$dnsinfo = dns_get_record($domain, DNS_TXT);
}
if (!empty($dnsinfo) && is_array($dnsinfo)) {
foreach ($dnsinfo as $info) {
if (($dnstype == 'SPF' && stripos($info['txt'], 'v=spf') !== false)
|| ($dnstype == 'DMARC' && stripos($info['txt'], 'v=dmarc') !== false)) {
$foundforemail++;
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitylow">'.$info['txt'].'</span>');
if (!empty($dnsinfo) && is_array($dnsinfo)) {
foreach ($dnsinfo as $info) {
if (($dnstype == 'SPF' && stripos($info['txt'], 'v=spf') !== false)
|| ($dnstype == 'DMARC' && stripos($info['txt'], 'v=dmarc') !== false)) {
$foundforemail++;
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitylow">'.$info['txt'].'</span>');
}
}
}
}
if (!$foundforemail) {
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitymedium">'.$langs->transnoentitiesnoconv("None").'</span>');
if (!$foundforemail) {
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitymedium">'.$langs->transnoentitiesnoconv("None").'</span>');
}
}
}
}
if ($text) {
print info_admin($langs->trans("SPFAndDMARCInformation").' :<br>'.$text, 0, 0, '1', '');
if ($text) {
print info_admin($langs->trans("SPFAndDMARCInformation").' :<br>'.$text, 0, 0, '1', '');
}
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=testsetup">'.$langs->trans("ClickHereToCheckSPFDMARCForSetup").'</a>';
print '<br><br>';
}
}

View File

@@ -2682,3 +2682,4 @@ MAIN_ENABLE_AJAX_TOOLTIP=Use Ajax lazy load of tooltip content with Ajax
MAIN_CACHE_COUNT=Keep the count of elements visible into badges in a cache (value may need several minutes to be up to date)
MAIN_DO_FETCH_IN_ONE_SQL_REQUEST=Load content of object and lines into one request
GoOnThisPageToInitBarCode=You can go on this page to initialize empty barcodes
ClickHereToCheckSPFDMARCForSetup=Get a summary of the SPF and DMARC setup of all domains