From dc787b67b43a3ac379d75e84da1a57fb76c135ab Mon Sep 17 00:00:00 2001 From: David Duque Date: Fri, 9 Sep 2022 16:29:01 +0100 Subject: [PATCH] Handle the case where the raw spf record exists but is None * Fixes #70 --- management/dns_update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/management/dns_update.py b/management/dns_update.py index eb6a6d0..18bbed0 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -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). # Skip if the user has set a custom SPF record. 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)) 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))