code.dwrz.net

Go monorepo.
Log | Files | Refs

commit 266169b9cc677877e24b878a95fd02fabdd461ac
parent 64b51ceee445845b817c61efdbdf822897e55675
Author: dwrz <dwrz@dwrz.net>
Date:   Tue, 18 Oct 2022 17:33:58 +0000

Add gmail pkg

Diffstat:
Apkg/gmail/auth.go | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/pkg/gmail/auth.go b/pkg/gmail/auth.go @@ -0,0 +1,36 @@ +package gmail + +import ( + "fmt" + "net/smtp" +) + +const Address = "smtp.gmail.com:587" + +type Auth struct { + Username string + Password string +} + +func (a *Auth) Start(server *smtp.ServerInfo) (string, []byte, error) { + return "LOGIN", []byte{}, nil +} + +func (a *Auth) Next(fromServer []byte, more bool) ([]byte, error) { + if more { + fs := string(fromServer) + + switch fs { + case "Username:": + return []byte(a.Username), nil + case "Password:": + return []byte(a.Password), nil + default: + return nil, fmt.Errorf( + "unrecognized fromServer: %s", fs, + ) + } + } + + return nil, nil +}