egulias / EmailValidator

PHP Email address validator
MIT License
11.45k stars 210 forks source link

dns_get_record in src/Validation/DNSCheckValidation.php return false for outlook emails. #382

Open SuryaJD opened 9 months ago

SuryaJD commented 9 months ago

Version: 4.0.1

I am trying to validate my Email address in my Laravel application, using the 'email:rfc,dns' rule. While checking the code in src/Validation/DNSCheckValidation.php I came to know that line 119 is giving me false as a return.

// Get all MX, A, and AAAA DNS records for the host // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149

$dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); while I tried dns_get_record("outlook.com"); instead it gave me the list of DNS.

is it a bug or am I facing this issue? Is there any way to configure the type of DNS in the above validation?

Also on Line 102, I notice that code in appending ' . ' to the hostname. Is there any particular reason for that?

ejunker commented 2 months ago

It must be an issue with your DNS server. When I run dns_get_record('outlook.com', DNS_MX + DNS_A + DNS_AAAA); I get back some results and most importantly it has an MX record.

    [
      "host" => "outlook.com",
      "class" => "IN",
      "ttl" => 330,
      "type" => "MX",
      "pri" => 5,
      "target" => "outlook-com.olc.protection.outlook.com",
    ]