gomail 邮件示例
示例
package main
import (
"gopkg.in/gomail.v2"
)
func main() {
m := gomail.NewMessage()
m.SetHeader("From", "robot@80.xyz")
m.SetHeader("To", "me@xiexianbin.cn", "me@166.xyz")
//m.SetAddressHeader("Cc", "dan@example.com", "Dan")
m.SetHeader("Subject", "Hello!")
m.SetBody("text/html", "Hello <b>xie</b> and <i>xianbin</i>!")
//m.Attach("/home/Alex/lolcat.jpg")
d := gomail.NewDialer("smtp.qiye.aliyun.com", 465, "robot@80.xyz", "xxx")
// Send the email to Bob, Cora and Dan.
if err := d.DialAndSend(m); err != nil {
panic(err)
}
}