fix
This commit is contained in:
parent
336e4708d1
commit
c062848a95
|
@ -1,12 +1,13 @@
|
||||||
Subject: Please confirm your {{ .CompanyName }} account
|
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!
|
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:
|
Please take a moment to confirm your email address by clicking the button below so we can activate your account:
|
||||||
|
|
||||||
<a href="{{ .ConfirmationLink }}" target="_blank" style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block; font-weight: bold;">Confirm My Account</a>
|
<a href="{{ .ConfirmationLink }}" target="_blank" style="background-color: #008CBA; color: #FFFFFF; text-decoration: none; padding: 10px 15px; border-radius: 3px; display:inline-block; font-weight: bold;">Confirm Account: .UserName</a>
|
||||||
|
|
||||||
|
|
||||||
Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content.
|
Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content.
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ type EmailFormat struct {
|
||||||
ConfirmationLink string // fs确认连接
|
ConfirmationLink string // fs确认连接
|
||||||
SenderName string // 发送人
|
SenderName string // 发送人
|
||||||
SenderTitle string // 发送标题
|
SenderTitle string // 发送标题
|
||||||
|
Extend map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmailSender
|
// EmailSender
|
||||||
|
@ -110,7 +111,12 @@ func (m *EmailSender) ProcessEmailTasks() {
|
||||||
go func() {
|
go func() {
|
||||||
defer func() { <-m.semaphore }() // Release a token
|
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)
|
err := smtp.SendMail("smtp.gmail.com:587", m.Auth, m.FromEmail, []string{emailformat.TargetEmail}, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to send email to %s: %v\n", emailformat, err)
|
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{
|
data := map[string]string{
|
||||||
"CompanyName": companyName,
|
"CompanyName": companyName,
|
||||||
|
@ -165,6 +171,10 @@ func RenderEmailTemplate(companyName, confirmationLink, senderName, senderTitle
|
||||||
"SenderTitle": senderTitle,
|
"SenderTitle": senderTitle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k, v := range extend {
|
||||||
|
data[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
var result bytes.Buffer
|
var result bytes.Buffer
|
||||||
err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
|
err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -72,6 +72,7 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
|
||||||
return resp.SetStatus(basic.CodeOAuthRegisterTokenErr)
|
return resp.SetStatus(basic.CodeOAuthRegisterTokenErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userName := token.Extend["first_name"].(string) + " " + token.Extend["last_name"].(string)
|
||||||
// 进入发送邮箱的系统
|
// 进入发送邮箱的系统
|
||||||
EmailManager.EmailTasks <- &EmailFormat{
|
EmailManager.EmailTasks <- &EmailFormat{
|
||||||
UniqueKey: "register-" + req.Email,
|
UniqueKey: "register-" + req.Email,
|
||||||
|
@ -80,6 +81,9 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist
|
||||||
ConfirmationLink: clurl,
|
ConfirmationLink: clurl,
|
||||||
SenderName: "support@fusenpack.com",
|
SenderName: "support@fusenpack.com",
|
||||||
SenderTitle: "register-valid",
|
SenderTitle: "register-valid",
|
||||||
|
Extend: map[string]string{
|
||||||
|
"UserName": userName,
|
||||||
|
},
|
||||||
} // email进入队
|
} // email进入队
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
|
|
@ -80,6 +80,9 @@ func (l *UserRegisterLogic) UserRegister(req *types.RequestUserRegister, userinf
|
||||||
ConfirmationLink: clurl,
|
ConfirmationLink: clurl,
|
||||||
SenderName: "support@fusenpack.com",
|
SenderName: "support@fusenpack.com",
|
||||||
SenderTitle: "register-valid",
|
SenderTitle: "register-valid",
|
||||||
|
Extend: map[string]string{
|
||||||
|
"UserName": req.FirstName + " " + req.LastName,
|
||||||
|
},
|
||||||
} // email进入队
|
} // email进入队
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user