From abddcb9a03f0fd711ab8ac35d05d2cb4ee6a6cb1 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 16 May 2020 23:38:19 +0530 Subject: [PATCH] Remove redundant SMTP LOGIN auth implementation --- internal/messenger/emailer.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/internal/messenger/emailer.go b/internal/messenger/emailer.go index 2e9f718..657a0e6 100644 --- a/internal/messenger/emailer.go +++ b/internal/messenger/emailer.go @@ -1,7 +1,6 @@ package messenger import ( - "errors" "fmt" "math/rand" "net/smtp" @@ -12,12 +11,6 @@ import ( const emName = "email" -// loginAuth is used for enabling SMTP "LOGIN" auth. -type loginAuth struct { - username string - password string -} - // Server represents an SMTP server's credentials. type Server struct { Name string @@ -56,7 +49,7 @@ func NewEmailer(srv ...Server) (*Emailer, error) { case "plain": auth = smtp.PlainAuth("", s.Username, s.Password, s.Host) case "login": - auth = &loginAuth{username: s.Username, password: s.Password} + auth = &smtppool.LoginAuth{Username: s.Username, Password: s.Password} case "": default: return nil, fmt.Errorf("unknown SMTP auth type '%s'", s.AuthProtocol) @@ -139,23 +132,3 @@ func (e *Emailer) Push(fromAddr string, toAddr []string, subject string, m []byt func (e *Emailer) Flush() error { return nil } - -// https://gist.github.com/andelf/5118732 -// Adds support for SMTP LOGIN auth. -func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { - return "LOGIN", []byte{}, nil -} - -func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { - if more { - switch string(fromServer) { - case "Username:": - return []byte(a.username), nil - case "Password:": - return []byte(a.password), nil - default: - return nil, errors.New("unkown SMTP fromServer") - } - } - return nil, nil -}