mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
33 lines
621 B
Go
33 lines
621 B
Go
package common
|
|
|
|
import (
|
|
"errors"
|
|
"net/smtp"
|
|
)
|
|
|
|
type outlookAuth struct {
|
|
username, password string
|
|
}
|
|
|
|
func LoginAuth(username, password string) smtp.Auth {
|
|
return &outlookAuth{username, password}
|
|
}
|
|
|
|
func (a *outlookAuth) Start(_ *smtp.ServerInfo) (string, []byte, error) {
|
|
return "LOGIN", []byte{}, nil
|
|
}
|
|
|
|
func (a *outlookAuth) 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("unknown fromServer")
|
|
}
|
|
}
|
|
return nil, nil
|
|
}
|