为什么当我尝试发送电子邮件时,我收到空电子邮件?
func contactHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
t, _ := template.ParseFiles("template/static/contact.html")
t.Execute(w, nil)
} else if r.Method == "POST" {
r.ParseForm()
msg := "Name: " + r.Form["name"][0] + ", Email: " + r.Form["email"][0] + ", Message: " + r.Form["message"][0]
println("out ", msg)
smtp.SendMail("smtp.gmail.com:587", smtp.PlainAuth("", "login", "password", "smtp.gmail.com"), "sender@mail.com", []string{"me@mail.com"}, []byte(msg))
http.Redirect(w, r, "/", 301)
}
}
但如果我将[]byte(msg)
更改为[]byte("TEST")
,我会收到包含测试字
答案 0 :(得分:1)
您无法根据需要制作电子邮件标题格式。电子邮件标头必须遵循RFC2822中定义的特定格式。尝试使用以下格式构建变量'msg':
IntStream.range(0, text1.size()).filter(i -> text.get(i).equals(text2.get(i)))
.forEach(ignored -> System.out.println("True"));
中的详细信息