我想获得smtp服务器的欢迎消息并检查是否包含特定关键字,这是我的实际代码:
DROP TABLE IF EXISTS jdbcTemp;
CREATE TABLE jdbcTemp
USING org.apache.spark.sql.jdbc
OPTIONS (...);
INSERT OVERWRITE TABLE jdbcTemp
SELECT * FROM my_spark_data;
DROP TABLE jdbcTemp;
代码返回此错误:package main
import (
"fmt"
"net"
"strings"
"time"
"net/smtp"
"errors"
)
type loginAuth struct {
username, password string
}
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 fromServer")
}
}
return nil, nil
}
func main() {
// attempt a connection
conn, err := net.DialTimeout("tcp", "88.198.24.108:25", 15 * time.Second)
defer conn.Close()
if err == nil {
buf := make([]byte, 32, 32)
conn.Read(buf)
if strings.Contains(string(buf), "Haraka") {
fmt.Println("this server not working with this application")
}
}
client, err := smtp.NewClient(conn, "88.198.24.108")
if err != nil {
fmt.Println("1>>", err)
return
}
err = client.Auth(&loginAuth{"info@example.com", "123456"})
if err != nil {
fmt.Println("2>>", err)
return
} else {
fmt.Println("auth successfull")
}
}
哪里错了?