package util


import (
	"crypto/tls"
	"gopkg.in/gomail.v2"
)


type HostInfo struct {
	address string
	port    int
}

func SendEmail(title string, content string, receiver ... string) {
	hostInfo := HostInfo{"mail.quantgroup.cn", 587}

	m := gomail.NewMessage()
	m.SetHeader("From", "program@quantgroup.cn")
	//m.SetHeader("To", []string{receiver})
	m.SetHeader("To", receiver...)
	m.SetHeader("Subject", title)
	m.SetBody("text/plain", content)

	userName := "program@quantgroup.cn"
	pwd := "Fuck147999!!!"
	d := gomail.NewDialer(hostInfo.address, hostInfo.port, userName, pwd)
	// 解决 x509: certificate signed by unknown authority
	d.TLSConfig = &tls.Config{InsecureSkipVerify: true}

	if err := d.DialAndSend(m); err != nil {
		panic(err)
	}

}
