package providers import ( "fmt" "os" "strconv" "testing" "time" "git.wenlab.co/joe/beaconfire" ) func TestSmtp(t *testing.T) { host := os.Getenv("SMTP_HOST") port, _ := strconv.Atoi(os.Getenv("SMTP_PORT")) username := os.Getenv("SMTP_USERNAME") password := os.Getenv("SMTP_PASSWORD") if len(host) <= 0 || len(username) <= 0 || len(password) <= 0 { fmt.Println("SMTP env is empty") return } FROM := "" TO := "" if len(FROM) <= 0 || len(TO) <= 0 { fmt.Println("need config FROM && TO") return } bf := NewSmtp(&OptionsSmtp{ Host: host, Port: port, InsecureSkipVerify: false, Username: username, Password: password, }) err := bf.Send(&beaconfire.BeaconParam{ From: FROM, To: []string{TO}, Ts: time.Now().Unix(), Title: "test", Content: "cfdfgddfdfdf", }) if err != nil { t.Error(err) } }