On production specific domains can not be resolved

Author: alexander-schranzCreated Feb 26, 2025Updated Mar 6, 2025

I have a IONOS and google cloud server and some A records fail to resolve the DNS_A + DNS_MX part:

bash
php -r 'require_once("vendor/autoload.php"); $dnsCheckValidation = new \Egulias\EmailValidator\Validation\DNSCheckValidation(); var_dump($dnsCheckValidation->isValid("[email protected]", new \Egulias\EmailValidator\EmailLexer())); var_dump($dnsCheckValidation->getError());'

Locally all works like expected.

If I change todo only a MX Lookup and not a A lookup all works like expected:

diff
-        $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_A + DNS_MX);
+        $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_MX);

So maybe change to something like:

php
        $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_MX);

        $dnsRecords = [];
        if (! $dnsRecordsResult->withError()) {
            $dnsRecords = $dnsRecordsResult->getRecords();
        }

        $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_A);

        if (! $dnsRecordsResult->withError()) {
            $dnsRecords = array_merge($dnsRecords, $dnsRecordsResult->getRecords());
        }

        // Combined check for A+MX+AAAA can fail with SERVFAIL, even in the presence of valid A/MX records
        $aaaaRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_AAAA);

        if (! $aaaaRecordsResult->withError()) {
            $dnsRecords = array_merge($dnsRecords, $aaaaRecordsResult->getRecords());
        }

Think this is similar to @crishoj https://github.com/egulias/EmailValidator/pull/376