示例代码
func sendEmail(username string, email string, msg uint64) {
m := gomail.NewMessage()
m.SetHeader("From", m.FormatAddress("abc@example.com","xxx 官网"))
m.SetHeader("To", email)
//m.SetAddressHeader("Cc", "dan@example.com", "Dan")
m.SetHeader("Subject", "注册信息")
m.SetBody("text/html", "最近的用户 <b>"+username+"</b> 您好! 欢迎您注册 xxx,您的验证码是 <span style='color:red'> "+strconv.FormatUint(msg, 10)+"</span>,祝您生活愉快!")
//m.Attach("/home/Alex/lolcat.jpg")
d := gomail.NewDialer("smtp.example.com", 587, "user", "123456")
// Send the email to Bob, Cora and Dan.
if err := d.DialAndSend(m); err != nil {
fmt.Println(err)
}
}