| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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,
- To: []string{TO},
- })
- err := bf.Send(&beaconfire.BeaconParam{
- Ts: time.Now().Unix(),
- Title: "test",
- Content: "cfdfgddfdfdf",
- })
- if err != nil {
- t.Error(err)
- }
- }
|