Skip to content

feat(email): 接入 Resend 事务邮件发信服务(OTP 用) - #50

Merged
longsizhuo merged 2 commits into
mainfrom
feat/resend-email
Jul 24, 2026
Merged

longsizhuo merged 2 commits into
mainfrom
feat/resend-email

Conversation

@longsizhuo

Copy link
Copy Markdown
Member

OTP 子系统的发信基础。后端直连 Resend REST API 发事务邮件。

为什么这样接

  • 不走 MCP:那个 mcp.resend.com 是给 agent 交互用的;生产后端运行时应调 REST API(同一个 key)。
  • 不自建 SMTP:Oracle 封了出站 25(实测),自建直发死路;云 IP 信誉也扛不住投递(见 AGENTS.md 会补)。
  • send-only key:后端只拿"只能发信"的 key(实测创建域名返回 401 restricted),域名管理留 dashboard——正确的最小权限。

改动

  • ResendEmailService.sendHtml(to, subject, html):HTTPS POST 到 api.resend.com/emails,失败记日志返回 false(不抛,OTP 调用方按可重试用户错误处理)。
  • resend.api-key / resend.from 走 env。域名验证前默认 onboarding@resend.dev。

验证

  • 3 单测(payload / 未配置不发 / 配置判定);全量 272 通过。
  • 真实发信已 curl 冒烟:Resend 返回 email id,到达账号邮箱。

待办(发给真实用户的前置)

需在 Resend dashboard 验证 involutionhell.com 发信域名(加 Cloudflare DKIM 记录),之后把 RESEND_FROM 换成 noreply@involutionhell.com。验证前只能发给账号本人。

🤖 Generated with Claude Code

https://claude.ai/code/session_01RtSNVtrEkCsFVHrbt4Zjgi

ResendEmailService:后端直连 Resend REST API(send-only key)发 HTML 邮件。
不走 MCP(agent 交互用)、不自建 SMTP(Oracle 封出站 25,见 AGENTS.md)。
发信失败只记日志返回 false,由调用方决定是否阻断。

- resend.api-key / resend.from 走 env(RESEND_API_KEY / RESEND_FROM)
- 域名验证前默认从 onboarding@resend.dev 发;验证 involutionhell.com 后
  把 resend.from 换成 noreply@involutionhell.com
- 3 测试(payload 构造 / 未配置不发 / 配置判定);真实发信已 curl 冒烟通过

后续 OTP 子系统(待注册态 + 验证码 + callback 集成 + 前端两步)调这个 service。
Copilot AI review requested due to automatic review settings July 19, 2026 18:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

- sendHtml 路由到 buildPayload,生产发信与被测路径统一(不再两份重复实现)
- 失败日志去掉收件邮箱与 Resend 响应体(响应体常回显 PII)
- InterruptedException 单独 catch 并恢复线程中断标志,不再吞掉
- 配了 key 却仍用沙箱 from(onboarding@resend.dev)时启动告警——避免"key 有效
  但给真实用户发信被拒"的隐性陷阱;application.properties 注释写明前置步骤
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants