diff --git a/server/auth/internal/logic/email_manager.go b/server/auth/internal/logic/email_manager.go index 3c95563c..15ac3c0c 100644 --- a/server/auth/internal/logic/email_manager.go +++ b/server/auth/internal/logic/email_manager.go @@ -222,6 +222,7 @@ func RenderEmailTemplate(templateName, companyName, confirmationLink, senderName } var result bytes.Buffer + result.Write([]byte("MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n")) err := tpls.ExecuteTemplate(&result, templateName, data) if err != nil { log.Fatal(err) diff --git a/server/auth/internal/logic/websocket_test.go b/server/auth/internal/logic/websocket_test.go index 69d779a6..2ebc4044 100644 --- a/server/auth/internal/logic/websocket_test.go +++ b/server/auth/internal/logic/websocket_test.go @@ -28,97 +28,13 @@ func TestEmailSend(t *testing.T) { 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) + subject := "Subject: Test email from Go!\n" + mime := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n" + body := "

Hello World!

" + msg := []byte(subject + mime + body) // 发送邮件 - err := smtp.SendMail(smtpServer+":587", auth, from, to, message) + err := smtp.SendMail(smtpServer+":587", auth, from, to, msg) if err != nil { log.Fatal(err) }