fix(mail): 发送失败时返回 SMTP 错误

- 发送邮件时若 `SMTP` 投递失败,直接返回 `502 Bad Gateway`。
- 新增测试覆盖投递失败场景,确认错误信息会透出。
This commit is contained in:
LanQin_
2026-06-16 15:10:28 +08:00
parent c1eb616759
commit 3093be2222
2 changed files with 28 additions and 1 deletions
+2 -1
View File
@@ -330,7 +330,8 @@ func (a *App) handleMailSend(w http.ResponseWriter, r *http.Request) {
}
if a.cfg.SMTPHost != "" {
if err := a.sendSMTP(mb.Address, allRecipients, mimeBytes); err != nil {
a.log.Warn("smtp delivery failed; keeping local sent copy", "error", err)
respondError(w, http.StatusBadGateway, "smtp delivery failed: "+err.Error())
return
}
}