{{.RejectReason}}
如有任何疑问,欢迎联系我们
package services import ( "bytes" "crypto/tls" "fmt" "html/template" "math" "net/smtp" "time" "github.com/jordan-wright/email" "goalfymax-admin/internal/config" ) type EmailService struct { host string port int username string password string sender string inviteURLPrefix string } // NewEmailService 创建邮件服务实例 func NewEmailService() *EmailService { cfg := config.GetConfig() return &EmailService{ host: cfg.Email.Host, port: cfg.Email.Port, username: cfg.Email.Username, password: cfg.Email.Password, sender: cfg.Email.Sender, inviteURLPrefix: cfg.Email.InviteURLPrefix, } } // SendInviteCodeApprovalEmail 发送邀请码审批通过邮件 func (s *EmailService) SendInviteCodeApprovalEmail(toEmail, inviteCode, language string, expiresAt *time.Time) error { var subject string if language == "en" { subject = "Your GoalfyAI Beta Access Invitation" } else { subject = "GoalfyAI 内测邀请函" } // 构造邮件内容 htmlContent := s.generateApprovalEmailHTML(inviteCode, language, expiresAt) return s.sendEmail(toEmail, subject, htmlContent) } // SendInviteCodeRejectionEmail 发送邀请码申请拒绝邮件 func (s *EmailService) SendInviteCodeRejectionEmail(toEmail, rejectReason string) error { subject := "关于您的 GoalfyAI 申请" // 构造邮件内容 htmlContent := s.generateRejectionEmailHTML(rejectReason) return s.sendEmail(toEmail, subject, htmlContent) } // generateApprovalEmailHTML 生成审批通过的邮件HTML func (s *EmailService) generateApprovalEmailHTML(inviteCode, language string, expiresAt *time.Time) string { if language == "en" { return s.GenerateApprovalEmailEN(inviteCode, expiresAt) } return s.GenerateApprovalEmailZH(inviteCode, expiresAt) } // formatExpiryTimeEN 格式化过期时间为英文显示(全部显示为小时,向上取整) func formatExpiryTimeEN(expiresAt *time.Time) string { if expiresAt == nil { return "until used" } now := time.Now() if expiresAt.Before(now) { return "expired" } duration := expiresAt.Sub(now) hours := int(math.Ceil(duration.Hours())) // 向上取整 if hours <= 0 { hours = 1 // 不足一小时算一小时 } if hours == 1 { return "1 hour" } return fmt.Sprintf("%d hours", hours) } // formatExpiryTimeZH 格式化过期时间为中文显示(全部显示为小时,向上取整) func formatExpiryTimeZH(expiresAt *time.Time) string { if expiresAt == nil { return "永久有效" } now := time.Now() if expiresAt.Before(now) { return "已过期" } duration := expiresAt.Sub(now) hours := int(math.Ceil(duration.Hours())) // 向上取整 if hours <= 0 { hours = 1 // 不足一小时算一小时 } return fmt.Sprintf("%d小时", hours) } // GenerateApprovalEmailEN 生成英文版审批通过邮件(导出用于测试) func (s *EmailService) GenerateApprovalEmailEN(inviteCode string, expiresAt *time.Time) string { expiryHours := formatExpiryTimeEN(expiresAt) tmplStr := `
Thank you again for your interest in GoalfyAI!
We're excited to let you know that your request for beta access has been approved.
You can now activate your GoalfyAI account using the link below:
👉 Activate Your Account
(This link is valid for {{.ExpiryHours}})
With this invite, you'll be among the first to explore our intelligent task execution system—designed for long-range, professional workflows. We'd love to hear your feedback as we continue to refine the experience.
Need help getting started? Visit our website for tips, use cases, and product updates:
🌐 GoalfyAI.com
Thanks again for joining us on this journey.
Let's build the future of intelligent tasks—together.
Warm regards,
The GoalfyAI Team
This email is sent automatically. Please do not reply.
For any questions, please contact hi@goalfyai.com
感谢您对 GoalfyAI 的关注与支持!
我们很高兴通知您,您的内测申请已通过审核。
请通过以下链接激活您的 GoalfyAI 账户:
👉 点击激活账户
(该链接在 {{.ExpiryHours}} 内有效)
通过本次邀请,您将率先体验我们为长周期专业任务打造的智能任务系统。我们也非常欢迎您在使用过程中给予反馈,帮助我们持续优化产品体验。
如需了解更多使用建议、典型场景或最新进展,欢迎访问官网:
🌐 GoalfyAI.com
感谢您的加入,
让我们一同开启智能任务的新篇章!
此致,
GoalfyAI 团队
本邮件为自动化发送,请勿回复。
如有疑问请联系 hi@goalfyai.com