diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 055980ae6d8..2777377edbe 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -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 ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$info['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 ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$info['txt'].''); + } } } - } - if (!$foundforemail) { - $text .= ($text ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$langs->transnoentitiesnoconv("None").''); + if (!$foundforemail) { + $text .= ($text ? '
' : '').'- '.$langs->trans("ActualMailDNSRecordFound", ''.$dnstype.'', ''.implode(', ', $listofemails).'', ''.$langs->transnoentitiesnoconv("None").''); + } } } - } - if ($text) { - print info_admin($langs->trans("SPFAndDMARCInformation").' :
'.$text, 0, 0, '1', ''); + if ($text) { + print info_admin($langs->trans("SPFAndDMARCInformation").' :
'.$text, 0, 0, '1', ''); + } + } else { + print ''.$langs->trans("ClickHereToCheckSPFDMARCForSetup").''; + print '

'; } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 01e0fc58ca6..49ac736d7e2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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