maddy/target/temporaryerr.go
fox.cpp 35c3b1c792
Restructure code tree
Root package now contains only initialization code and 'dummy' module.

Each module now got its own package. Module packages are grouped by
their main purpose (storage/, target/, auth/, etc). Shared code is
placed in these "group" packages.

Parser for module references in config is moved into config/module.

Code shared by tests (mock modules, etc) is placed in testutils.
2019-09-08 16:06:38 +03:00

30 lines
605 B
Go

package target
import (
"errors"
"net"
"net/textproto"
"github.com/emersion/go-smtp"
)
func IsTemporaryErr(err error) bool {
if protoErr, ok := err.(*textproto.Error); ok {
return (protoErr.Code / 100) == 4
}
if smtpErr, ok := err.(*smtp.SMTPError); ok {
return (smtpErr.Code / 100) == 4
}
if netErr, ok := err.(net.Error); ok {
return netErr.Temporary()
}
if err == ErrTLSRequired {
return false
}
// Connection error? Assume it is temporary.
return true
}
var ErrTLSRequired = errors.New("TLS is required for outgoing connections but target server doesn't support STARTTLS")