fix(mail): 发送失败时返回 SMTP 错误
- 发送邮件时若 `SMTP` 投递失败,直接返回 `502 Bad Gateway`。 - 新增测试覆盖投递失败场景,确认错误信息会透出。
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user