test email server with old password when password is empty and username equals

This commit is contained in:
liugq 2023-07-28 16:02:54 +08:00
parent 3709f5683d
commit ce98378a7c
1 changed files with 12 additions and 0 deletions

View File

@ -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...)