commit 5338394a86c9f3d8ee54ed667423aef96535263c
parent c18e97e8345054ee67db1cf4416be9c866c0d919
Author: dwrz <dwrz@dwrz.net>
Date: Fri, 2 Dec 2022 15:06:42 +0000
Add gmail pkg
Diffstat:
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
+}