emails: ignore DNS errors (#36502)
This commit is contained in:
parent
1b98a8e952
commit
083658ee5a
|
@ -51,8 +51,12 @@ def validate_email_spf(value, strict=False):
|
|||
if not allowed_records:
|
||||
return
|
||||
email_domain = value.split('@')[-1]
|
||||
txt_records = sum([r.strings for r in dns.resolver.query(email_domain, 'TXT')], [])
|
||||
spf_records = [x for x in txt_records if x.startswith('v=spf1 ')]
|
||||
try:
|
||||
txt_records = sum([r.strings for r in dns.resolver.query(email_domain, 'TXT')], [])
|
||||
except dns.exception.DNSException:
|
||||
spf_records = []
|
||||
else:
|
||||
spf_records = [x for x in txt_records if x.startswith('v=spf1 ')]
|
||||
if not strict and not spf_records:
|
||||
return
|
||||
for spf_record in spf_records:
|
||||
|
|
Loading…
Reference in New Issue