diff --git a/fs_template/email_register.tpl b/fs_template/email_register.tpl
index 353f01fe..3565d19e 100644
--- a/fs_template/email_register.tpl
+++ b/fs_template/email_register.tpl
@@ -1,12 +1,13 @@
Subject: Please confirm your {{ .CompanyName }} account
-Dear,
+Dear {{ .UserName }},
Thank you for registering an account with {{ .CompanyName }}. We are thrilled to have you join our community!
Please take a moment to confirm your email address by clicking the button below so we can activate your account:
-Confirm My Account
+Confirm Account: .UserName
+
Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content.
diff --git a/server/auth/internal/logic/email_manager.go b/server/auth/internal/logic/email_manager.go
index a0c86349..24a1c16a 100644
--- a/server/auth/internal/logic/email_manager.go
+++ b/server/auth/internal/logic/email_manager.go
@@ -58,6 +58,7 @@ type EmailFormat struct {
ConfirmationLink string // fs确认连接
SenderName string // 发送人
SenderTitle string // 发送标题
+ Extend map[string]string
}
// EmailSender
@@ -110,7 +111,12 @@ func (m *EmailSender) ProcessEmailTasks() {
go func() {
defer func() { <-m.semaphore }() // Release a token
- content := RenderEmailTemplate(emailformat.CompanyName, emailformat.ConfirmationLink, emailformat.SenderName, emailformat.SenderTitle)
+ content := RenderEmailRegisterTemplate(emailformat.CompanyName,
+ emailformat.ConfirmationLink,
+ emailformat.SenderName,
+ emailformat.SenderTitle,
+ emailformat.Extend,
+ )
err := smtp.SendMail("smtp.gmail.com:587", m.Auth, m.FromEmail, []string{emailformat.TargetEmail}, content)
if err != nil {
log.Printf("Failed to send email to %s: %v\n", emailformat, err)
@@ -156,7 +162,7 @@ func (m *EmailSender) ClearExpiredTasks() {
}
}
-func RenderEmailTemplate(companyName, confirmationLink, senderName, senderTitle string) []byte {
+func RenderEmailRegisterTemplate(companyName, confirmationLink, senderName, senderTitle string, extend map[string]string) []byte {
data := map[string]string{
"CompanyName": companyName,
@@ -165,6 +171,10 @@ func RenderEmailTemplate(companyName, confirmationLink, senderName, senderTitle
"SenderTitle": senderTitle,
}
+ for k, v := range extend {
+ data[k] = v
+ }
+
var result bytes.Buffer
err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
if err != nil {
diff --git a/server/auth/internal/logic/useremailregisterlogic.go b/server/auth/internal/logic/useremailregisterlogic.go
index 487fdf74..be88c9b4 100644
--- a/server/auth/internal/logic/useremailregisterlogic.go
+++ b/server/auth/internal/logic/useremailregisterlogic.go
@@ -72,6 +72,7 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
return resp.SetStatus(basic.CodeOAuthRegisterTokenErr)
}
+ userName := token.Extend["first_name"].(string) + " " + token.Extend["last_name"].(string)
// 进入发送邮箱的系统
EmailManager.EmailTasks <- &EmailFormat{
UniqueKey: "register-" + req.Email,
@@ -80,6 +81,9 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
ConfirmationLink: clurl,
SenderName: "support@fusenpack.com",
SenderTitle: "register-valid",
+ Extend: map[string]string{
+ "UserName": userName,
+ },
} // email进入队
return resp.SetStatus(basic.CodeOK)
diff --git a/server/auth/internal/logic/userregisterlogic.go b/server/auth/internal/logic/userregisterlogic.go
index 0ae610dc..6d621e48 100644
--- a/server/auth/internal/logic/userregisterlogic.go
+++ b/server/auth/internal/logic/userregisterlogic.go
@@ -80,6 +80,9 @@ func (l *UserRegisterLogic) UserRegister(req *types.RequestUserRegister, userinf
ConfirmationLink: clurl,
SenderName: "support@fusenpack.com",
SenderTitle: "register-valid",
+ Extend: map[string]string{
+ "UserName": req.FirstName + " " + req.LastName,
+ },
} // email进入队
return resp.SetStatus(basic.CodeOK)