添加QQ邮箱的测试

This commit is contained in:
Yun
2024-04-12 16:24:16 +08:00
parent 33c009df47
commit 6800ac9fbc
+23
View File
@@ -39,3 +39,26 @@ func TestMail(t *testing.T) {
err := mail.Send(msg) err := mail.Send(msg)
fmt.Println(err) fmt.Println(err)
} }
func TestQQ(t *testing.T) {
// 发件人邮箱
from := "995116474@qq.com"
// 授权码,而非密码
authCode := "xxxxxxxxxxxxxxxxxxxxxx"
// 收件人邮箱,可以是多个收件人
to := []string{"yun@yun.ink"}
// 邮件服务器信息
smtpHost := "smtp.qq.com"
smtpPort := "587" // 或使用465,根据你的SMTP服务器要求设置
mail := mailx.NewMailx(from, authCode, smtpHost, smtpPort)
msg := mailx.Message{
To: to,
Subject: "test mail",
Body: "测试",
}
err := mail.Send(msg)
fmt.Println(err)
}