This commit is contained in:
eson
2023-11-10 17:14:38 +08:00
parent 7c76066d04
commit 36aa17bd1a
4 changed files with 149 additions and 33 deletions

View File

@@ -26,48 +26,55 @@ func TestEmailSend(t *testing.T) {
// 设置发件人和收件人信息
from := "support@fusenpack.com"
to := []string{"474420502@qq.com"}
// to := []string{"qq474420502@gmail.com"}
// to := []string{"outlook_7D27A8300A1B3F01@outlook.com"}
// 设置smtp服务器地址,端口和认证信息
smtpServer := "smtp.gmail.com"
auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer)
msg := []byte(`Subject: Password Reset Request for Your Account;
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";
From: "Fusen";
var buf bytes.Buffer
tpls.ExecuteTemplate(&buf, "test.tpl", map[string]any{
"CompanyName": "FusenPack",
})
// msg := []byte(`Subject: Password Reset Request for Your Account;
// MIME-version: 1.0;
// Content-Type: text/html; charset="UTF-8";
// From: "Fusen";
<html>
<head>
<title>Password Reset for Your {{.CompanyName}} Account</title>
</head>
<body>
// <html>
// <head>
// <title>Password Reset for Your {{.CompanyName}} Account</title>
// </head>
// <body>
<p>Dear {{.UserName}},</p>
// <p>Dear {{.UserName}},</p>
<p>We have received your request to reset the password for your {{.CompanyName}} account.</p>
// <p>We have received your request to reset the password for your {{.CompanyName}} account.</p>
<p>To proceed with the password reset, please click the button below to open the Reset Password page:</p>
// <p>To proceed with the password reset, please click the button below to open the Reset Password page:</p>
<div style="margin: 1em 0;">
<a href="{{.ConfirmationLink}}" target="_blank"
style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block;">
Reset Password
</a>
</div>
// <div style="margin: 1em 0;">
// <a href="{{.ConfirmationLink}}" target="_blank"
// style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block;">
// Reset Password
// </a>
// </div>
<p>Please note that this password reset confirmation link will expire in 60 minutes. If you have any further questions, feel free to reach out to us.</p>
// <p>Please note that this password reset confirmation link will expire in 60 minutes. If you have any further questions, feel free to reach out to us.</p>
<p>Regards,</p>
// <p>Regards,</p>
<p>{{.SenderName}}<br>
{{.SenderTitle}}<br>
{{.CompanyName}}</p>
// <p>{{.SenderName}}<br>
// {{.SenderTitle}}<br>
// {{.CompanyName}}</p>
</body>
</html>`)
// </body>
// </html>`)
msg := buf.Bytes()
// 发送邮件
err := smtp.SendMail(smtpServer+":587", auth, from, to, msg)
if err != nil {