From ce98378a7c53d49d358dfd3a5633bd21c3d1ffee Mon Sep 17 00:00:00 2001 From: liugq Date: Fri, 28 Jul 2023 16:02:54 +0800 Subject: [PATCH] test email server with old password when password is empty and username equals --- plugin/api/email/server.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugin/api/email/server.go b/plugin/api/email/server.go index 48cfc8d6..b6a961bc 100644 --- a/plugin/api/email/server.go +++ b/plugin/api/email/server.go @@ -293,6 +293,18 @@ func (h *EmailAPI) testEmailServer(w http.ResponseWriter, req *http.Request, ps h.WriteError(w, err.Error(), http.StatusInternalServerError) return } + if reqBody.Auth.Password == "" && reqBody.ID != "" { + obj := model.EmailServer{} + obj.ID = reqBody.ID + _, err := orm.Get(&obj) + if err != nil { + h.WriteError(w, err.Error(), http.StatusInternalServerError) + return + } + if reqBody.Auth.Username == obj.Auth.Username { + reqBody.Auth.Password = obj.Auth.Password + } + } message := gomail.NewMessage() message.SetHeader("From", reqBody.Auth.Username) message.SetHeader("To", reqBody.SendTo...)