1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-23 15:37:01 +00:00

courier: Consider not finding any MX/A records a permanent error

Currently, if we can't find a mail server for a domain, we consider that
a transient failure (semi-accidentally, as we iterate over the (empty)
list of MXs and fall through the list).

It should be treated as a permanent error, in line with other DNS
issues (which is not ideal but seems to be generally accepted
behaviour).
This commit is contained in:
Alberto Bertogli
2017-03-01 00:18:25 +00:00
parent 0eeb964534
commit 9539cfd34d
2 changed files with 16 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ func (s *SMTP) Deliver(from string, to string, data []byte) (error, bool) {
a.stsPolicy = s.fetchSTSPolicy(a.tr, a.toDomain)
mxs, err := lookupMXs(a.tr, a.toDomain, a.stsPolicy)
if err != nil {
if err != nil || len(mxs) == 0 {
// Note this is considered a permanent error.
// This is in line with what other servers (Exim) do. However, the
// downside is that temporary DNS issues can affect delivery, so we

View File

@@ -163,4 +163,19 @@ func TestSMTPErrors(t *testing.T) {
}
}
func TestNoMXServer(t *testing.T) {
fakeMX["to"] = []string{}
s, tmpDir := newSMTP(t)
defer os.Remove(tmpDir)
err, permanent := s.Deliver("me@me", "to@to", []byte("data"))
if err == nil {
t.Errorf("delivery worked, expected failure")
}
if !permanent {
t.Errorf("expected permanent failure, got transient (%v)", err)
}
t.Logf("got permanent failure, as expected: %v", err)
}
// TODO: Test STARTTLS negotiation.