This commit is contained in:
momo 2023-11-10 17:21:36 +08:00
commit c29964a05b
2 changed files with 148 additions and 25 deletions

116
fs_template/test.tpl Normal file
View File

@ -0,0 +1,116 @@
Subject: Please confirm your {{ .CompanyName }} account;
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";
From: "Fusen Support";
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单状态流转</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
</style>
<body>
<div style="
width: 50%;
max-width: 600px;
min-width: 350px;
margin: 0 auto;
background-color: #FFFFFF;">
<div>
<h1><img style="
width: 22%;
height: 6%;
padding: 50px 0 30px 8%;" src="https://fusenstorage.s3.us-east-2.amazonaws.com/2c3938702c52d46550fffae344f1619dd71c447f3b19882045205fcd8adbd6bf" alt=""></h1>
</div>
<div>
<h2 style="
width: 84%;
font-size: 47px;
font-family: Gotham-Bold, Gotham;
font-weight: bold;
color: #212121;
line-height: 58px;
padding-bottom: 24px;
padding-left: 8%;">The status of your order has changed!</h2>
<p style="
width: 84%;
font-size: 14px;
font-weight: normal;
color: #212121;
line-height: 21px;
padding-bottom: 40px;
padding-left: 8%;">
Your order has been changed from "原状态" to "现状态".</p>
<a href="" style="
display: block;
text-align: center;
width: 80%;
height: 24px;
font-size: 16px;
font-family: Gotham-Bold, Gotham;
font-weight: bold;
color: #FFFFFF;
line-height: 24px;
margin: 0 auto;
background-color: #FF7F00;
padding: 15px 12px;
margin-bottom: 60px;
border-radius: 200px;
text-decoration: none;">Check Your Order</a>
</div>
<div>
<div style="
width: 80%;
background-color: #F8F8F8;
padding: 20px 30px;
margin: 0 auto;">
<h3 style="
height: 28px;
font-size: 16px;
font-family: Gotham-Bold, Gotham;
font-weight: bold;
color: #212121;
line-height: 28px;">Search Logo, Get Design</h3>
<p style=" height: 21px;
font-size: 12px;
font-family: Gotham-Medium, Gotham;
font-weight: 500;
color: #212121;
line-height: 21px;">Our products</p>
<p style=" height: 21px;
font-size: 12px;
font-family: Gotham-Medium, Gotham;
font-weight: 500;
color: #212121;
line-height: 21px;">Try it out</p>
<div style="
width: 100%;
padding: 17px 0 10px 0 ;
border-bottom: 1px solid #CCCCCC;
margin-bottom: 10px;">
<img style="width: 14px;height: 14px;" src="https://fusenstorage.s3.us-east-2.amazonaws.com/7d6e04f8a90762210f8b8fc307198776b8dc42998adc90bab41e178053552b2c" alt="">
<span> support@fusenpack.com</span>
</div>
<span style="
width: 74px;
height: 21px;
font-size: 12px;
font-weight: normal;
color: #999999;
line-height: 21px;
display: block;
cursor: pointer;
text-decoration: none;">Unsubscribe</span>
</div>
</div>
</div>
</body>
</html>

View File

@ -26,48 +26,55 @@ func TestEmailSend(t *testing.T) {
// 设置发件人和收件人信息 // 设置发件人和收件人信息
from := "support@fusenpack.com" from := "support@fusenpack.com"
to := []string{"474420502@qq.com"} to := []string{"474420502@qq.com"}
// to := []string{"qq474420502@gmail.com"}
// to := []string{"outlook_7D27A8300A1B3F01@outlook.com"}
// 设置smtp服务器地址,端口和认证信息 // 设置smtp服务器地址,端口和认证信息
smtpServer := "smtp.gmail.com" smtpServer := "smtp.gmail.com"
auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer) auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer)
msg := []byte(`Subject: Password Reset Request for Your Account; var buf bytes.Buffer
MIME-version: 1.0; tpls.ExecuteTemplate(&buf, "test.tpl", map[string]any{
Content-Type: text/html; charset="UTF-8"; "CompanyName": "FusenPack",
From: "Fusen"; })
// msg := []byte(`Subject: Password Reset Request for Your Account;
// MIME-version: 1.0;
// Content-Type: text/html; charset="UTF-8";
// From: "Fusen";
<html> // <html>
<head> // <head>
<title>Password Reset for Your {{.CompanyName}} Account</title> // <title>Password Reset for Your {{.CompanyName}} Account</title>
</head> // </head>
<body> // <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;"> // <div style="margin: 1em 0;">
<a href="{{.ConfirmationLink}}" target="_blank" // <a href="{{.ConfirmationLink}}" target="_blank"
style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block;"> // style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block;">
Reset Password // Reset Password
</a> // </a>
</div> // </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> // <p>{{.SenderName}}<br>
{{.SenderTitle}}<br> // {{.SenderTitle}}<br>
{{.CompanyName}}</p> // {{.CompanyName}}</p>
</body> // </body>
</html>`) // </html>`)
msg := buf.Bytes()
// 发送邮件 // 发送邮件
err := smtp.SendMail(smtpServer+":587", auth, from, to, msg) err := smtp.SendMail(smtpServer+":587", auth, from, to, msg)
if err != nil { if err != nil {