This is a creation in Article, where the information may have evolved or changed.
Go language to send mail, you can use the SMTP package, two key functions:
Func Plainauth (identity, username, password, host string) Auth
Func SendMail (addr string, a Auth, from string, to []string, msg []byte) error
Just started to play, very curious about the mail title is how to set in, after all, from the code did not see Settitle. Later found to parse msg get title, sender, recipient, message format, message content , etc. msg needs to be written in a certain format: to: xxx\r\nfrom: xxxx\r\nSubject: xxxx\r\ncontent-type:text/html; charset=utf-8\r\n\r\n[Email Content]
Func ( This*TestController) SendMail () {subject:="This is golang test email ..."User:="xxxxx@163.com"To := []string{"xxxxx@163.com"} Nickname:="Dyao"content:="mail Body ... .."ContentType:="content-type:text/html; Charset=utf-8"msg:= []byte("To :"+ Strings. Join (To,",") +"\r\nfrom:"+ Nickname +"<"+ user +">\r\nsubject:"+ Subject +"\ r \ n"+ ContentType +"\r\n\r\n"+content) Auth:=SMTP. Plainauth ("", user,"Testpassword", "smtp.163.com",) Err:=SMTP. SendMail ("smtp.163.com:25", auth, User, to, []byte(msg),)ifErr! =nil{Log. Fatal (ERR)}Else{log. Printf ("Mail send:\r\n%s", msg)}}