Handle the case where the raw spf record exists but is None

* Fixes #70
This commit is contained in:
David Duque 2022-09-09 16:29:01 +01:00
parent 09cf3b3755
commit dc787b67b4

View file

@ -397,7 +397,8 @@ def build_zone(domain,
# the domain, and no one else (unless the user is using an SMTP relay and authorized other servers). # the domain, and no one else (unless the user is using an SMTP relay and authorized other servers).
# Skip if the user has set a custom SPF record. # Skip if the user has set a custom SPF record.
if not has_rec(None, "TXT", prefix="v=spf1 "): if not has_rec(None, "TXT", prefix="v=spf1 "):
if settings.get("SMTP_RELAY_SPF_RECORD", "").strip() != "" and relay_on: rawrecord = settings.get("SMTP_RELAY_SPF_RECORD", "")
if rawrecord is not None and rawrecord.strip() != "" and relay_on:
records.append((None, "TXT", settings.get("SMTP_RELAY_SPF_RECORD"), "Added by your SMTP Relay provider so that they can send @%s mail on your behalf." % domain, None)) records.append((None, "TXT", settings.get("SMTP_RELAY_SPF_RECORD"), "Added by your SMTP Relay provider so that they can send @%s mail on your behalf." % domain, None))
elif spf_extra is None: elif spf_extra is None:
records.append((None, "TXT", "v=spf1 mx -all", "Recommended. Specifies that only the box is permitted to send @%s mail." % domain, None)) records.append((None, "TXT", "v=spf1 mx -all", "Recommended. Specifies that only the box is permitted to send @%s mail." % domain, None))