emails: fix deliverability check when MX lookup returns nonexistent domain.

Fix the email deliverability check to return undeliverable when the MX lookup returns a domain or IP
address that is invalid or that refuses connections. For example, `yeah.com` returns the invalid IP
address 0.0.0.0 for its MX record.
This commit is contained in:
evazion
2022-11-20 22:30:32 -06:00
parent 80faee67db
commit f9b8e83bb0

View File

@@ -349,6 +349,9 @@ module Danbooru
response = conn.rcptto(address) rescue $!
return response.is_a?(Net::SMTPFatalError)
end
rescue Errno::ECONNREFUSED
# nobody@yeah.com (MX: 0.0.0.0)
true
rescue
false
end