邮件采用"net/smtp"官方库,接收参数:SendMail(sender string, subject string, content []byte, receiver []string),如何用template的模式,将一个表格插入正文content []byte里,在线等,急需
w, err := cli.Data()
msg.Reset()
msg.WriteString(fmt.Sprintf("From: <%s>\r\n", sender))
msg.WriteString(fmt.Sprintf("To: <%s>\r\n", strings.Join(receiver, ">,<")))
msg.WriteString(fmt.Sprintf("Subject: %s\r\n", subject))
msg.WriteString("Content-Type: text/html; charset=UTF-8\r\n\r\n")
msg.Write(content)
_, err = w.Write(msg.Bytes())
w.Close()
有疑问加站长微信联系(非本文作者)