Files
goalfylearning-admin/test/preview_email.go

53 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"os"
"time"
"goalfymax-admin/internal/config"
"goalfymax-admin/internal/services"
)
func main() {
fmt.Println("==========================================================")
fmt.Println("邮件模板预览")
fmt.Println("==========================================================")
// 加载配置
config.LoadConfig("./etc/config.yaml")
// 创建邮件服务
emailService := services.NewEmailService()
inviteCode := "GFY-SAMPLE01-ABCD"
expiresAt := time.Now().Add(72 * time.Hour)
// 生成中文邮件 HTML
fmt.Println("\n=== 生成中文邮件预览 ===")
htmlZh := emailService.GenerateApprovalEmailZH(inviteCode, &expiresAt)
fileZh := "./docs/email_preview_zh.html"
if err := os.WriteFile(fileZh, []byte(htmlZh), 0644); err != nil {
fmt.Printf("✗ 保存失败: %v\n", err)
} else {
fmt.Printf("✓ 已保存到: %s\n", fileZh)
}
// 生成英文邮件 HTML
fmt.Println("\n=== 生成英文邮件预览 ===")
htmlEn := emailService.GenerateApprovalEmailEN(inviteCode, &expiresAt)
fileEn := "./docs/email_preview_en.html"
if err := os.WriteFile(fileEn, []byte(htmlEn), 0644); err != nil {
fmt.Printf("✗ 保存失败: %v\n", err)
} else {
fmt.Printf("✓ 已保存到: %s\n", fileEn)
}
fmt.Println("\n==========================================================")
fmt.Println("预览文件已生成!")
fmt.Println("==========================================================")
fmt.Println("\n打开以下文件查看邮件效果")
fmt.Printf(" 中文版: open %s\n", fileZh)
fmt.Printf(" 英文版: open %s\n", fileEn)
}