more helpful error message when the queue tries to deliver a message but the remote host is not listed in the mta-sts policy

based on questions on irc by Nemain where this better error message would
probably have made the problem easier to find and fix.
This commit is contained in:
Mechiel Lukkien
2023-06-01 16:15:33 +02:00
parent cafbfc5fdf
commit 77d78191f8
2 changed files with 19 additions and 2 deletions

View File

@ -572,8 +572,12 @@ func deliver(resolver dns.Resolver, m Msg) {
// ../rfc/8461:913
if policy != nil && policy.Mode == mtasts.ModeEnforce && !policy.Matches(h.Domain) {
errmsg = fmt.Sprintf("mx host %s does not match enforced mta-sts policy", h.Domain)
qlog.Error("mx host does not match enforce mta-sts policy, skipping", mlog.Field("host", h.Domain))
var policyHosts []string
for _, mx := range policy.MX {
policyHosts = append(policyHosts, mx.LogString())
}
errmsg = fmt.Sprintf("mx host %s does not match enforced mta-sts policy with hosts %s", h.Domain, strings.Join(policyHosts, ","))
qlog.Error("mx host does not match enforce mta-sts policy, skipping", mlog.Field("host", h.Domain), mlog.Field("policyhosts", policyHosts))
continue
}