mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-28 20:56:03 +00:00
smtp: Try all entries in MX, not just the first one
Currently, we pick the first host in the MX list, and attempt delivery there. If it fails, we just report the failure to the queue, which will wait for some time and then try again. This is not ideal: we should fall back to the other MXs in the list, as the first host could be having issues for a long time, and not attempting with the rest just delays delivery. This patch implements the fallback, so we try all MXs before deciding to report a failed delivery (unless, of course, an MX returned a permanent failure).
This commit is contained in:
@@ -87,7 +87,9 @@ func TestSMTP(t *testing.T) {
|
||||
addr := fakeServer(t, responses)
|
||||
host, port, _ := net.SplitHostPort(addr)
|
||||
|
||||
fakeMX["to"] = host
|
||||
// Put a non-existing host first, so we check that if the first host
|
||||
// doesn't work, we try with the rest.
|
||||
fakeMX["to"] = []string{"nonexistinghost", host}
|
||||
*smtpPort = port
|
||||
|
||||
s, tmpDir := newSMTP(t)
|
||||
@@ -148,7 +150,7 @@ func TestSMTPErrors(t *testing.T) {
|
||||
addr := fakeServer(t, rs)
|
||||
host, port, _ := net.SplitHostPort(addr)
|
||||
|
||||
fakeMX["to"] = host
|
||||
fakeMX["to"] = []string{host}
|
||||
*smtpPort = port
|
||||
|
||||
s, tmpDir := newSMTP(t)
|
||||
|
||||
Reference in New Issue
Block a user