mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 05:40:50 +01:00
Added fix to LOGIN auth module, in case the server responds with "Authentication successful"
This commit is contained in:
parent
030eba8cfd
commit
6a446bd4bd
1 changed files with 8 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue