From 6a446bd4bd12fa0275f184ac84b397ffaa16dad5 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 20 Mar 2022 19:28:20 +0100 Subject: [PATCH] Added fix to LOGIN auth module, in case the server responds with "Authentication successful" --- auth/login.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/auth/login.go b/auth/login.go index 1385b69..64e2ecc 100644 --- a/auth/login.go +++ b/auth/login.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/smtp" + "strings" ) type loginAuth struct { @@ -18,6 +19,10 @@ const ( // ServerRespPassword represents the "Password:" response by the SMTP server 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 @@ -63,5 +68,8 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { return []byte(a.password), nil } } + if strings.HasSuffix(string(fromServer), ServerRespAuthSuccess) { + return nil, nil + } return nil, fmt.Errorf("unexpected server response: %s", string(fromServer)) }