Skip to content

Commit 73f4825

Browse files
janverbJoshData
authored andcommitted
Resolve email domain as unambiguous fully qualified domain name (#30)
If dnspython receives a domain name that does not end in a period it may also try resolving it as not fully qualified. This can cause domains to be incorrectly resolved as if they exist. This can be tested by adding a line `search mailinator.com` to /etc/resolv.conf. With that line added, the address `test@asdf.asdf` will be considered deliverable by email-validator. The solution is to append a period to the domain before passing it to dnspython. This is valid because the domain part of the email address is not allowed to end in a period, and is required to be interpreted as fully qualified.
1 parent 987b806 commit 73f4825

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

email_validator/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ def validate_email_deliverability(domain, domain_i18n, timeout=DEFAULT_TIMEOUT):
240240
# Check that the domain resolves to an MX record. If there is no MX record,
241241
# try an A or AAAA record which is a deprecated fallback for deliverability.
242242

243+
# Add a trailing period to ensure the domain name is treated as fully qualified.
244+
domain += '.'
245+
243246
try:
244247
resolver = dns.resolver.get_default_resolver()
245248

0 commit comments

Comments
 (0)