Fix NULL MX handling and tighten DNS resolving specs (#28607)

This commit is contained in:
Claire authored and GitHub committed 2024-01-05 11:07:57 +00:00
1 parent 9699ea22d6
commit 6ad0fb5a77
4 files changed
+16 -1

No files matched your search

+1
View File
@@ -47,6 +47,7 @@ class EmailMxValidator < ActiveModel::Validator
dns.timeouts = 5
records = dns.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }
next if records == [''] # This domain explicitly rejects emails
([domain] + records).uniq.each do |hostname|
ips.concat(dns.getresources(hostname, Resolv::DNS::Resource::IN::A).to_a.map { |e| e.address.to_s })