package main
import ( "log" "net/smtp" )
var ( from = "test@immwind.com" // To From Subject 非必须 msg = []byte("To:hi@example.com\r\n" + "From: test@example.com\r\n" + "Subject: Hello World\r\n" + "\r\n" + "这是测试邮件\n\r") recipients = []string{"hi@immwind.com"} )
func main() { hostname := "smtp.exmail.qq.com" auth := smtp.PlainAuth("", "test@example.com", "password", hostname)
err := smtp.SendMail(hostname+":25", auth, from, recipients, msg) if err != nil { log.Fatal(err) } }