Skip to content

Commit

Permalink
Added fix to LOGIN auth module, in case the server responds with "Aut…
Browse files Browse the repository at this point in the history
…hentication successful"
  • Loading branch information
wneessen committed Mar 20, 2022
1 parent 030eba8 commit 6a446bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions auth/login.go
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/smtp"
"strings"
)

type loginAuth struct {
Expand All @@ -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
Expand Down Expand Up @@ -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))
}

0 comments on commit 6a446bd

Please sign in to comment.