golang邮箱登录验证(可以作为代替企业OA登录)
import ( "crypto/tls" "fmt" "github.com/go-gomail/gomail" ) func LoginByEmail(host string, port int, username string, passwd string) (bool,error) { dialer := gomail.NewDialer(host, port, username, passwd) //解决x509报错的问题。证书不通过。跳过证书验证 config := &tls.Config{ServerName: host, InsecureSkipVerify: true} dialer.TLSConfig = config _,err := dialer.Dial() if err != nil { fmt.Println(err) fmt.Println("登录失败") return false, err } return true, nil }