From f4c20673ff6cebf50995e0b20c8adb9bcfa47c3a Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Fri, 25 Aug 2023 14:32:28 +0200 Subject: [PATCH] don't generate duplicate spf record if hostname is equal to domain name, e.g. postmaster@mail.domain. the assumption has been that the hostname is something like mail., when setting up mox with the quickstart for user@. but users can use the quickstart for postmaster@mail. as well. for issue #46 by x8x, thanks for reporting! --- mox-/admin.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mox-/admin.go b/mox-/admin.go index c470e1b..4b3953c 100644 --- a/mox-/admin.go +++ b/mox-/admin.go @@ -453,18 +453,24 @@ func DomainRecords(domConf config.Domain, domain dns.Domain) ([]string, error) { "; Once your setup is working, you may want to increase the TTL.", "$TTL 300", "", + } - "; For the machine, only needs to be created for the first domain added.", - fmt.Sprintf(`%-*s IN TXT "v=spf1 a -all"`, 20+len(d), h+"."), // ../rfc/7208:2263 ../rfc/7208:2287 - "", + if d != h { + records = append(records, + "; For the machine, only needs to be created once, for the first domain added.", + fmt.Sprintf(`%-*s IN TXT "v=spf1 a -all"`, 20+len(d), h+"."), // ../rfc/7208:2263 ../rfc/7208:2287 + "", + ) + } + records = append(records, "; Deliver email for the domain to this host.", fmt.Sprintf("%s. MX 10 %s.", d, h), "", "; Outgoing messages will be signed with the first two DKIM keys. The other two", "; configured for backup, switching to them is just a config change.", - } + ) var selectors []string for name := range domConf.DKIM.Selectors { selectors = append(selectors, name)