fix get auth info

This commit is contained in:
liugq 2023-07-31 17:31:40 +08:00
parent 877a2b9414
commit c99fce0ae6
1 changed files with 5 additions and 1 deletions

View File

@ -338,7 +338,7 @@ func (h *EmailAPI) testEmailServer(w http.ResponseWriter, req *http.Request, ps
h.WriteError(w, err.Error(), http.StatusInternalServerError)
return
}
if reqBody.Auth.Password == "" && reqBody.CredentialID != "" {
if reqBody.CredentialID != "" {
auth, err := common.GetBasicAuth(&reqBody.EmailServer)
if err != nil {
h.WriteError(w, err.Error(), http.StatusInternalServerError)
@ -346,6 +346,10 @@ func (h *EmailAPI) testEmailServer(w http.ResponseWriter, req *http.Request, ps
}
reqBody.Auth = &auth
}
if reqBody.Auth == nil {
h.WriteError(w, "auth info required", http.StatusInternalServerError)
return
}
message := gomail.NewMessage()
message.SetHeader("From", reqBody.Auth.Username)
message.SetHeader("To", reqBody.SendTo...)