在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
发邮件功能可以调用比如: qq 163 新浪的邮箱进行发送 , 使用go-smtp这个类库来发送比较简单 , 例如下面的例子:
package tools import ( "github.com/emersion/go-sasl" "github.com/emersion/go-smtp" "strings" ) func Send(server string,from string,password string,to []string,subject string,body string)error{ auth := sasl.NewPlainClient("", from, password) msg := strings.NewReader( "From: "+from+"\r\n"+ "To: "+strings.Join(to,",")+"\r\n"+ "Subject: "+subject+"\r\n" + "\r\n" + body+"\r\n") err := smtp.SendMail(server, auth, from, to, msg) if err != nil { return err } return nil }
|
请发表评论