This is a creation in Article, where the information may have evolved or changed.
Pro-Test available
Package Mainimport (M "Chutils/mail" "FMT") func main () {email: = M.newemail ("305860361@qq.com", "Test subject", "tested") Err: = M.sen Demail (email) if err! = Nil {fmt. Print (ERR)}}
<pre name= "code" class= "CSharp" >package mailimport ("FMT" "NET/SMTP" "Strings") const (HOST = "smtp.163.com" SERVER_ADDR = "Smtp.163.com:25" USER = "a15207146487@163.com"//mailbox to send mail password = "IADBLVAHQEPHDPZL" // The password to send the mail mailbox) type email struct {To string ' to ' subject string "Subject" MSG string "msg"}func newemail (to, subject, msg string) *email {return &email{to:to, Subject:subject, Msg:msg}}func SendEmail (Email *email) Error {auth: = SMTP . Plainauth ("", USER, PASSWORD, HOST) SendTo: = Strings. Split (Email.to, ";") Done: = Make (chan error, 1024x768) go func () {defer close (done) for _, V: = range SendTo {str: = strings. Replace ("From:" +user+ "~to:" +v+ "~subject:" +email.subject+ "~ ~", "~", "\ r \ n",-1) + Email.msgerr: = SMTP. SendMail (Server_addr,auth,user,[]string{v},[]byte (str),) Done <-Err}} () for I: = 0; I < Len (sendTo); i++ {fmt. Println (<-done)}return Nil}