Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-06 10:00:17 +08:00
commit 9110e2bb35
4 changed files with 78 additions and 27 deletions

View File

@ -1,20 +1,29 @@
Subject: Please confirm your {{ .CompanyName }} account Subject: Please confirm your {{ .CompanyName }} account;
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";
From: "Fusen Support";
Dear {{ .UserName }},
Thank you for registering an account with {{ .CompanyName }}. We are thrilled to have you join our community! <html>
<body>
Please take a moment to confirm your email address by clicking the button below so we can activate your account: <p>Dear <span style="color: red;">{{.UserName}}</span>,</p>
<p>Thank you for registering an account with {{ .CompanyName }}. We are thrilled to have you join our community!</p>
<p>Please take a moment to confirm your email address by clicking the button below so we can activate your account:</p>
<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> <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>
<p>Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content.</p>
Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content. <p>If you did not register for {{ .CompanyName }}, please disregard this email. Let us know if you have any other questions!</p>
If you did not register for {{ .CompanyName }}, please disregard this email. Let us know if you have any other questions!
Regards, Regards,
{{ .SenderName }} <p><span>{{.SenderName}}</span><br>
{{ .SenderTitle }} <span>{{.SenderTitle}}</span><br>
{{ .CompanyName }} <span>{{.CompanyName}}</span></p>
<body>
<html>

View File

@ -1,21 +1,32 @@
Subject: Password Reset Request for Your {{ .CompanyName }} Account Subject: Password Reset Request for Your {{ .CompanyName }} Account
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";
From: "Fusen Support";
Dear {{ .UserName }},
We have received your request to reset the password for your {{ .CompanyName }} account. <html>
<body>
To proceed with the password reset, please click the button below to open the Reset Password page: <p>Dear <span style="color: red;">{{.UserName}}</span>,</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>
<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; font-family: Arial, sans-serif; font-size: 14px; font-weight: bold;"> 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>
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>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>
Regards, <p>Regards,</p>
{{ .SenderName }}<br>
{{ .SenderTitle }}<br> <p><span>{{.SenderName}}</span><br>
{{ .CompanyName }} <span>{{.SenderTitle}}</span><br>
<span>{{.CompanyName}}</span></p>
</body>
</html>

View File

@ -222,7 +222,7 @@ func RenderEmailTemplate(templateName, companyName, confirmationLink, senderName
} }
var result bytes.Buffer var result bytes.Buffer
result.Write([]byte("MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n")) // result.Write([]byte("MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n"))
err := tpls.ExecuteTemplate(&result, templateName, data) err := tpls.ExecuteTemplate(&result, templateName, data)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -28,10 +28,41 @@ func TestEmailSend(t *testing.T) {
auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer) auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer)
subject := "Subject: Test email from Go!\n" msg := []byte(`Subject: Password Reset Request for Your Account;
mime := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n" MIME-version: 1.0;
body := "<html><body><h1>Hello World!</h1></body></html>" Content-Type: text/html; charset="UTF-8";
msg := []byte(subject + mime + body) From: "Fusen";
<html>
<head>
<title>Password Reset for Your {{.CompanyName}} Account</title>
</head>
<body>
<p>Dear {{.UserName}},</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>
<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>Regards,</p>
<p>{{.SenderName}}<br>
{{.SenderTitle}}<br>
{{.CompanyName}}</p>
</body>
</html>`)
// 发送邮件 // 发送邮件
err := smtp.SendMail(smtpServer+":587", auth, from, to, msg) err := smtp.SendMail(smtpServer+":587", auth, from, to, msg)