diff --git a/server/auth/internal/logic/email_manager.go b/server/auth/internal/logic/email_manager.go index 57ad20cb..3c95563c 100644 --- a/server/auth/internal/logic/email_manager.go +++ b/server/auth/internal/logic/email_manager.go @@ -5,10 +5,10 @@ import ( "fmt" "fusenapi/utils/check" "fusenapi/utils/fstpl" + "html/template" "log" "net/smtp" "sync" - "text/template" "time" "github.com/zeromicro/go-zero/core/logx" diff --git a/server/auth/internal/logic/websocket_test.go b/server/auth/internal/logic/websocket_test.go index 812ab97e..69d779a6 100644 --- a/server/auth/internal/logic/websocket_test.go +++ b/server/auth/internal/logic/websocket_test.go @@ -7,6 +7,7 @@ import ( "io" "log" "net/http" + "net/smtp" "testing" "github.com/474420502/requests" @@ -16,6 +17,113 @@ import ( "github.com/zeromicro/go-zero/core/logx" ) +func TestEmailSend(t *testing.T) { + + // 设置发件人和收件人信息 + from := "support@fusenpack.com" + to := []string{"474420502@qq.com"} + + // 设置smtp服务器地址,端口和认证信息 + smtpServer := "smtp.gmail.com" + + auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer) + + body := `
+
+
+
+
+
+
+ +
+
+ + + + + + + + +
+
+ +
+
+
+ 3e +
+
+ 474420502@qq.com +
+
+
+
+
+
+
+   +
+
+ +
+
+
+
+
+
+
+ ------------------ 原始邮件 ------------------ +
+
+
+ + 发件人: + + "support" <support@fusenpack.com>; +
+
+ + 发送时间: + +  2023年9月5日(星期二) 晚上6:16 +
+
+ + 收件人: + +  "3e"<474420502@qq.com>; + +
+
+
+
+ + 主题: + +  Simple Mail +
+
+
+
+
+ +
+
` + // 构建邮件内容 + message := []byte("To: " + to[0] + "\r\n" + + "Subject: Simple Mail\r\n" + + "\r\n" + + body) + + // 发送邮件 + err := smtp.SendMail(smtpServer+":587", auth, from, to, message) + if err != nil { + log.Fatal(err) + } +} + func TestPost(t *testing.T) { r := mux.NewRouter() diff --git a/utils/fstpl/auto_parse.go b/utils/fstpl/auto_parse.go index 9bd69850..3e28dd56 100644 --- a/utils/fstpl/auto_parse.go +++ b/utils/fstpl/auto_parse.go @@ -1,11 +1,11 @@ package fstpl import ( + "html/template" "log" "os" "runtime" "strings" - "text/template" ) func AutoParseTplFiles() *template.Template {