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.<domain>, when
setting up mox with the quickstart for user@<domain>. but users can use the
quickstart for postmaster@mail.<domain> as well.

for issue #46 by x8x, thanks for reporting!
This commit is contained in:
Mechiel Lukkien 2023-08-25 14:32:28 +02:00
parent 61a5eb61a4
commit f4c20673ff
No known key found for this signature in database

View file

@ -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)