%s,您好:
+%s
+%s
+验证码将在 %d 分钟后失效。
+如果不是您本人操作,请忽略此邮件。
+diff --git a/backend/services/verification/delivery.go b/backend/services/verification/delivery.go index c4c40755..e9c11d63 100644 --- a/backend/services/verification/delivery.go +++ b/backend/services/verification/delivery.go @@ -238,7 +238,7 @@ func CodeHTML(challenge Challenge, code string) string { if strings.TrimSpace(recipientName) == "" { recipientName = challenge.Email } - return buildCodeHTML(recipientName, code, verificationExpiryMinutes(challenge)) + return buildCodeHTML(challenge.Purpose, recipientName, code, verificationExpiryMinutes(challenge)) } func verificationExpiryMinutes(challenge Challenge) int { @@ -251,7 +251,26 @@ func verificationExpiryMinutes(challenge Challenge) int { return int(DefaultTTL / time.Minute) } -func buildCodeHTML(recipientName, code string, expiresInMinutes int) string { +func buildCodeHTML(purpose Purpose, recipientName, code string, expiresInMinutes int) string { + headerColor := "#4f46e5" + headerTitle := "邮箱验证码" + actionPrompt := "您的验证码是:" + + switch purpose { + case PurposeExternalEmailBind, PurposeExternalEmailChange: + headerColor = "#0ea5e9" + headerTitle = "通知邮箱验证" + actionPrompt = "您正在添加额外的通知邮箱,请输入以下验证码完成验证。" + case PurposePasswordRecover, PurposePasswordChange: + headerColor = "#7c3aed" + headerTitle = "密码重置" + actionPrompt = "我们收到了您的密码重置请求,请输入以下验证码完成重置。" + default: + headerColor = "#4f46e5" + headerTitle = "邮箱验证码" + actionPrompt = "您的验证码是:" + } + return fmt.Sprintf(` @@ -261,31 +280,200 @@ func buildCodeHTML(recipientName, code string, expiresInMinutes int) string { + +
+%s,您好:
+%s
+%s
+验证码将在 %d 分钟后失效。
+如果不是您本人操作,请忽略此邮件。
+