package email import "fmt" // BuildVerifyCodeEmail returns a locale-appropriate subject and HTML body for // the verification code email. Chinese domains get a Chinese email; all others // get an English one. func BuildVerifyCodeEmail(toEmail, code string) (subject, body string) { domain := toEmail[lastIndex(toEmail, '@')+1:] if chineseDomainRe.MatchString(domain) { return buildVerifyCodeZH(code) } return buildVerifyCodeEN(code) } func buildVerifyCodeZH(code string) (subject, body string) { subject = "您的验证码" body = fmt.Sprintf(` 验证码
TexPixel

验证您的邮箱

请使用以下验证码完成注册。验证码仅对您本人有效,请勿分享给他人。

%s

验证码 10 分钟内有效,请尽快使用

如果您没有请求此验证码,可以忽略本邮件,您的账户仍然安全。
© 2025 TexPixel. 保留所有权利。

`, code) return } func buildVerifyCodeEN(code string) (subject, body string) { subject = "Your verification code" body = fmt.Sprintf(` Verification Code
TexPixel

Verify your email address

Use the verification code below to complete your registration. Never share this code with anyone.

%s

This code expires in 10 minutes

If you didn’t request this code, you can safely ignore this email. Your account is still secure.
© 2025 TexPixel. All rights reserved.

`, code) return } // lastIndex returns the last index of sep in s, or -1. func lastIndex(s string, sep byte) int { for i := len(s) - 1; i >= 0; i-- { if s[i] == sep { return i } } return -1 }