Added fix to LOGIN auth module, in case the server responds with "Authentication successful"

This commit is contained in:
Winni Neessen 2022-03-20 19:28:20 +01:00
parent 030eba8cfd
commit 6a446bd4bd
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/smtp" "net/smtp"
"strings"
) )
type loginAuth struct { type loginAuth struct {
@ -18,6 +19,10 @@ const (
// ServerRespPassword represents the "Password:" response by the SMTP server // ServerRespPassword represents the "Password:" response by the SMTP server
ServerRespPassword = "Password:" ServerRespPassword = "Password:"
// ServerRespAuthSuccess represents the "Authentication successful:" response that is
// by sent by some SMTP servers
ServerRespAuthSuccess = "Authentication successful"
) )
// LoginAuth returns an Auth that implements the LOGIN authentication // LoginAuth returns an Auth that implements the LOGIN authentication
@ -63,5 +68,8 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
return []byte(a.password), nil return []byte(a.password), nil
} }
} }
if strings.HasSuffix(string(fromServer), ServerRespAuthSuccess) {
return nil, nil
}
return nil, fmt.Errorf("unexpected server response: %s", string(fromServer)) return nil, fmt.Errorf("unexpected server response: %s", string(fromServer))
} }