beego邮件发送

beego邮件发送

以QQ邮箱为例,其他邮箱大同小异

import (
	"github.com/astaxie/beego/utils"
)
	email := "456@qq.com"  //接收者邮箱
	emailConfig := `{"username":"123@qq.com","password":"abcdefg","host":"smtp.qq.com","port":587}`
	emailConn := utils.NewEMail(emailConfig)
	emailConn.From = "123@qq.com"   //发送者邮箱
	emailConn.To = []string{email}
	emailConn.Subject = "邮件标题"
	emailConn.Text = "邮件内容"
	emailConn.Send()
  • username为发送者的邮箱,注意:password不是QQ邮箱的密码,通过上面生成授权码。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42601663/article/details/123919884