package main import ( "log" "net/smtp" "flag" "fmt" "strings" ) var ( subject = flag.String("s","","subject of the mail") body = flag.String("b", "", "body of email") reciMail = flag.String("m","","recipient mail address") ) func main(){ flag.Parse() sub := fmt.Sprintf("subject: %s\r\n\r\n",*subject) content := *body mailList := strings.Split(*reciMail,",") fmt.Println(sub) fmt.Println(content) fmt.Println(mailList) auth := smtp.PlainAuth( "", "jackma_www@126.com", "12345pwd", "smtp.126.com", ) err := smtp.SendMail( "smtp.126.com:25", auth, "jackma_yyy@126.com", mailList, []byte(sub+content), ) if err != nil { log.Fatal(err) } }
有疑问加站长微信联系(非本文作者)