mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-07 17:47:14 +00:00
smtp: Distinguish permanent errors
This patch makes the SMTP courier distinguish permanent errors, so the queue can decide whether to retry or not. It's based on the SMTP replies: 5xy is considerent permanent, anything else is transient (including errors other than protocol issues).
This commit is contained in:
@@ -3,6 +3,7 @@ package smtp
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/smtp"
|
||||
"net/textproto"
|
||||
@@ -11,6 +12,24 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestIsPermanent(t *testing.T) {
|
||||
cases := []struct {
|
||||
err error
|
||||
permanent bool
|
||||
}{
|
||||
{&textproto.Error{499, ""}, false},
|
||||
{&textproto.Error{500, ""}, true},
|
||||
{&textproto.Error{599, ""}, true},
|
||||
{&textproto.Error{600, ""}, false},
|
||||
{fmt.Errorf("something"), false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if p := IsPermanent(c.err); p != c.permanent {
|
||||
t.Errorf("%v: expected %v, got %v", c.err, c.permanent, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsASCII(t *testing.T) {
|
||||
cases := []struct {
|
||||
str string
|
||||
|
||||
Reference in New Issue
Block a user