File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 1313
1414class 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 (), '' );
You can’t perform that action at this time.
0 commit comments