fix: raise an error if MX lookup times out during sending

This avoids potentially sending mail to the A record when an MX query times out.

closes #2833
This commit is contained in:
Adam Cooke
2024-03-01 21:36:07 +00:00
parent 77e818a472
commit fadca88f45
7 changed files with 231 additions and 33 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ class SMTPSender < BaseSender
#
# @return [Array<String>]
def resolve_mx_records_for_domain
hostnames = DNSResolver.local.mx(@domain).map(&:last)
hostnames = DNSResolver.local.mx(@domain, raise_timeout_errors: true).map(&:last)
return [SMTPClient::Server.new(@domain)] if hostnames.empty?
hostnames.map { |hostname| SMTPClient::Server.new(hostname) }