From c281ee3b61e8ab53ff118866d72618ae8cce582b Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 13 Mar 2017 12:54:22 -0400 Subject: Updating server dependancies. Also adding github.com/jaytaylor/html2text and gopkg.in/gomail.v2 (#5748) --- vendor/gopkg.in/gomail.v2/auth.go | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 vendor/gopkg.in/gomail.v2/auth.go (limited to 'vendor/gopkg.in/gomail.v2/auth.go') diff --git a/vendor/gopkg.in/gomail.v2/auth.go b/vendor/gopkg.in/gomail.v2/auth.go new file mode 100644 index 000000000..4bcdd0620 --- /dev/null +++ b/vendor/gopkg.in/gomail.v2/auth.go @@ -0,0 +1,67 @@ +package gomail + +import ( + "bytes" + "errors" + "fmt" + "net/smtp" +) + +// plainAuth is an smtp.Auth that implements the PLAIN authentication mechanism. +// It fallbacks to the LOGIN mechanism if it is the only mechanism advertised +// by the server. +type plainAuth struct { + username string + password string + host string + login bool +} + +func (a *plainAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { + if server.Name != a.host { + return "", nil, errors.New("gomail: wrong host name") + } + + var plain, login bool + for _, a := range server.Auth { + switch a { + case "PLAIN": + plain = true + case "LOGIN": + login = true + } + } + + if !server.TLS && !plain && !login { + return "", nil, errors.New("gomail: unencrypted connection") + } + + if !plain && login { + a.login = true + return "LOGIN", nil, nil + } + + return "PLAIN", []byte("\x00" + a.username + "\x00" + a.password), nil +} + +func (a *plainAuth) Next(fromServer []byte, more bool) ([]byte, error) { + if !a.login { + if more { + return nil, errors.New("gomail: unexpected server challenge") + } + return nil, nil + } + + if !more { + return nil, nil + } + + switch { + case bytes.Equal(fromServer, []byte("Username:")): + return []byte(a.username), nil + case bytes.Equal(fromServer, []byte("Password:")): + return []byte(a.password), nil + default: + return nil, fmt.Errorf("gomail: unexpected server challenge: %s", fromServer) + } +} -- cgit v1.2.3-1-g7c22