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

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

@ -1,9 +1,8 @@
package gmodel
import (
"time"
"gorm.io/gorm"
"time"
)
// fs_message_log 消息记录表

View File

@ -119,10 +119,7 @@ type AllModelsGen struct {
FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存
FsWebSet *FsWebSetModel // fs_web_set 网站配置表
FsZipCode *FsZipCodeModel // fs_zip_code 邮编表
LdapApis *LdapApisModel // ldap_apis
LdapCasbinRule *LdapCasbinRuleModel // ldap_casbin_rule 规则权限表
LdapMenus *LdapMenusModel // ldap_menus
LdapUsers *LdapUsersModel // ldap_users
}
@ -243,10 +240,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsUserStock: NewFsUserStockModel(gdb),
FsWebSet: NewFsWebSetModel(gdb),
FsZipCode: NewFsZipCodeModel(gdb),
LdapApis: NewLdapApisModel(gdb),
LdapCasbinRule: NewLdapCasbinRuleModel(gdb),
LdapMenus: NewLdapMenusModel(gdb),
LdapUsers: NewLdapUsersModel(gdb),
}
return models
}

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 {