From 0bf94a0c2bd68d4380c48eed297271d72290d35c Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 22 Oct 2025 20:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 1 + service/toolService.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/handler/tool.go b/handler/tool.go index 6131452..5a506ae 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -471,6 +471,7 @@ func SendMailTool(c *gin.Context) { if err := c.ShouldBind(&req); err == nil { //发送邮件 if user.Role == "admin" { + log.Println("send mail req:", req) go service.SendEmail(req.To, req.Title, req.Content) resp.Code, resp.Data, resp.Message = proto.SuccessCode, "mail will be sent", "success" } else { diff --git a/service/toolService.go b/service/toolService.go index c6da1ab..e22379b 100644 --- a/service/toolService.go +++ b/service/toolService.go @@ -104,6 +104,10 @@ func SendEmail(email, subject, body string) { em.SmtpUserName = "354425203@qq.com" em.SmtpPort = 587 em.ImapPort = 993 + if email == "" || subject == "" || body == "" { + log.Println("tool send email fail: email or subject or body is empty") + return + } err := em.Send(subject, body, []string{email}) if err != nil { fmt.Println("send mail error:", err)