Skip to content

Commit ebaaf5b

Browse files
authored
perform AAAA check separately (fixes #301) (#376)
1 parent d11195e commit ebaaf5b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Validation/DNSCheckValidation.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
class DNSCheckValidation implements EmailValidation
1515
{
16-
/**
17-
* @var int
18-
*/
19-
protected const DNS_RECORD_TYPES_TO_CHECK = DNS_MX + DNS_A + DNS_AAAA;
2016

2117
/**
2218
* Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
@@ -149,7 +145,7 @@ protected function checkDns($host)
149145
*/
150146
private function validateDnsRecords($host): bool
151147
{
152-
$dnsRecordsResult = $this->dnsGetRecord->getRecords($host, static::DNS_RECORD_TYPES_TO_CHECK);
148+
$dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_A + DNS_MX);
153149

154150
if ($dnsRecordsResult->withError()) {
155151
$this->error = new InvalidEmail(new UnableToGetDNSRecord(), '');
@@ -158,6 +154,13 @@ private function validateDnsRecords($host): bool
158154

159155
$dnsRecords = $dnsRecordsResult->getRecords();
160156

157+
// Combined check for A+MX+AAAA can fail with SERVFAIL, even in the presence of valid A/MX records
158+
$aaaaRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_AAAA);
159+
160+
if (! $aaaaRecordsResult->withError()) {
161+
$dnsRecords = array_merge($dnsRecords, $aaaaRecordsResult->getRecords());
162+
}
163+
161164
// No MX, A or AAAA DNS records
162165
if ($dnsRecords === []) {
163166
$this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');

0 commit comments

Comments
 (0)