Skip to content

docs: add SMTP sending tutorial - #1059

Open
dashitongzhi wants to merge 3 commits into
dreamhunter2333:mainfrom
dashitongzhi:docs/smtp-sending-tutorial-20260613090754
Open

docs: add SMTP sending tutorial#1059
dashitongzhi wants to merge 3 commits into
dreamhunter2333:mainfrom
dashitongzhi:docs/smtp-sending-tutorial-20260613090754

Conversation

@dashitongzhi

@dashitongzhi dashitongzhi commented Jun 13, 2026

Copy link
Copy Markdown

Summary

  • Adds a new docs/SMTP_SENDING.md guide covering SMTP send configuration, app passwords, supported providers (Gmail, Outlook, custom), common errors and fixes, and 3 working curl examples for sending mail via the Cloudflare email worker API

Motivation

Closes #609 — community requested a follow-up to the existing 小白版教程 (beginner tutorial) covering outgoing mail/SMTP.

Test Plan

  • Follow each step locally against a test Cloudflare worker deployment
  • Render markdown to verify formatting and code blocks
  • Cross-check environment variable names against the worker source

File Added

Path LOC
docs/SMTP_SENDING.md 277

Summary by CodeRabbit

  • 文档
    • 将“发送邮件/SMTP 发信教程”拆分并更新为双语 VitePress 文档,新增 Cloudflare Dashboard/CLI 的 SMTP_CONFIG 密钥配置位置说明与完整填入部署步骤。
    • 补充 SMTP_CONFIG 与发件域名的归一化后精确相等匹配规则(不支持子域/后缀),以及未命中后的通道回退顺序与更多 Provider 示例(Gmail/Outlook/自托管)。
    • 新增邮件发送与查询的可直接运行 curl 调试示例,并扩展常见故障排查(认证/连接/证书/DNS/垃圾箱)。

Copilot AI review requested due to automatic review settings June 13, 2026 01:13
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f7ff280-3e85-42cc-9a61-737051a9a5ec

📥 Commits

Reviewing files that changed from the base of the PR and between 528db29 and 76dc332.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • CHANGELOG_EN.md
  • vitepress-docs/docs/en/guide/common-issues.md
  • vitepress-docs/docs/en/guide/config-send-mail.md
  • vitepress-docs/docs/en/guide/feature/send-mail-api.md
  • vitepress-docs/docs/zh/guide/common-issues.md
  • vitepress-docs/docs/zh/guide/config-send-mail.md
  • vitepress-docs/docs/zh/guide/feature/send-mail-api.md
✅ Files skipped from review due to trivial changes (7)
  • CHANGELOG_EN.md
  • vitepress-docs/docs/zh/guide/feature/send-mail-api.md
  • vitepress-docs/docs/en/guide/common-issues.md
  • CHANGELOG.md
  • vitepress-docs/docs/en/guide/feature/send-mail-api.md
  • vitepress-docs/docs/zh/guide/common-issues.md
  • vitepress-docs/docs/en/guide/config-send-mail.md

📝 Walkthrough

Walkthrough

中英文文档补充了 SMTP 配置规则、Cloudflare 配置步骤、服务商示例、发送接口 curl 示例和常见问题排查,并同步更新了 changelog 条目。

Changes

SMTP 邮件发送指南

Layer / File(s) Summary
SMTP 配置与示例
vitepress-docs/docs/en/guide/config-send-mail.md, vitepress-docs/docs/zh/guide/config-send-mail.md
补充 SMTP_CONFIG 的匹配规则、Cloudflare Dashboard 配置步骤,以及 Gmail、Outlook/Microsoft 365 和自建 SMTP 示例。
发送接口示例
vitepress-docs/docs/en/guide/feature/send-mail-api.md, vitepress-docs/docs/zh/guide/feature/send-mail-api.md
新增 /api/send_mail/external/api/send_mail/api/sendboxcurl 示例。
常见问题排查
vitepress-docs/docs/en/guide/common-issues.md, vitepress-docs/docs/zh/guide/common-issues.md
扩展 SMTP 认证、连接、证书、DNS 和垃圾邮件投递的排查说明。
版本说明更新
CHANGELOG.md, CHANGELOG_EN.md
在 v1.10.0(main) 的 changelog 条目中补充 SMTP 文档更新说明。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Review effort 2/5

Suggested reviewers

  • dreamhunter2333

Poem

我是一只小兔,耳朵竖起,
SMTP_CONFIG 对齐后再启程。
curl 一跳,邮件飞到云里,
FAQ 小路把迷雾拨清。
🐇📨 叮咚,发送成功咯!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了新增 SMTP 发信教程这一主要变更。
Linked Issues check ✅ Passed 新增的 SMTP 配置、Cloudflare 部署、示例 provider、排障和 curl 示例,满足 #609 需要的具体发送邮件教程。
Out of Scope Changes check ✅ Passed 改动均为 SMTP 教程、问题排查与变更日志更新,未见与目标无关的功能性改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a step-by-step SMTP sending tutorial to help users configure outbound email for Cloudflare Temp Email, complementing the existing reference docs and addressing common setup questions (ref: #609).

Changes:

  • Introduces a new SMTP-focused walkthrough for setting SMTP_CONFIG in Cloudflare Workers.
  • Adds provider-specific configuration recipes (Gmail, Outlook/M365, custom SMTP).
  • Documents common errors and includes curl examples for the send APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/SMTP_SENDING.md Outdated
}'
```

### 7.3 Check what is left in the outbox
Comment thread docs/SMTP_SENDING.md Outdated
Comment on lines +135 to +138
> [!WARNING]
> Google Workspace admins can disable App Passwords org-wide. If
> `530-5.5.1 Authentication required` keeps appearing, ask your admin to
> allow less-secure-app access or switch to Resend.
Comment thread docs/SMTP_SENDING.md Outdated
Comment on lines +209 to +210
| `Error: connect ECONNREFUSED / ETIMEDOUT` | Cloudflare IPs blocked by the relay, or wrong port/secure flag | Use port 465 with `secure: true`; if your ISP relays do not allow Cloudflare, switch to Resend/Mailgun |
| `Error: self signed certificate` | `secure: true` against a server whose TLS cert isn't trusted | Fix the cert, or set `secure: false` with port 587 + STARTTLS |

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/SMTP_SENDING.md (1)

70-105: 补充说明 SMTP_CONFIG 顶层键的精确匹配契约及回退条件

  • getDomainMapValue 会对 SMTP_CONFIG 的顶层 key 和 mailDomain 都做 normalizeDomaintrim + toLowerCase),然后用 === 做精确相等匹配;不做子域/后缀匹配(除非 key 本身就是该子域)。
  • send_mail_api.ts 里只有当匹配到的 smtpConfig 存在时才会走 SMTP;否则会依次走 resend / sendMailBinding(或已验证地址列表),若这些也都未启用最终会抛错而非永远“静默禁用”。

建议在 3. SMTP_CONFIG 章节正文再把“归一化后精确相等 + 不匹配则跳过 SMTP(可能最终报错)”明确写出来。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/SMTP_SENDING.md` around lines 70 - 105, Clarify in the "3. The
`SMTP_CONFIG` JSON" section that getDomainMapValue normalizes both the
SMTP_CONFIG top-level keys and the mailDomain using normalizeDomain (trim +
toLowerCase) and then requires exact equality (===) — no implicit
subdomain/suffix matching — and explicitly state that send_mail_api.ts will only
use SMTP when a matching smtpConfig exists; otherwise it falls back to resend /
sendMailBinding (or verified-address list) and may ultimately throw an error if
no channel is available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/SMTP_SENDING.md`:
- Around line 70-105: Clarify in the "3. The `SMTP_CONFIG` JSON" section that
getDomainMapValue normalizes both the SMTP_CONFIG top-level keys and the
mailDomain using normalizeDomain (trim + toLowerCase) and then requires exact
equality (===) — no implicit subdomain/suffix matching — and explicitly state
that send_mail_api.ts will only use SMTP when a matching smtpConfig exists;
otherwise it falls back to resend / sendMailBinding (or verified-address list)
and may ultimately throw an error if no channel is available.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e6d672d-cfcc-4ec7-b2e1-473711d93e1a

📥 Commits

Reviewing files that changed from the base of the PR and between c924b71 and 726e216.

📒 Files selected for processing (1)
  • docs/SMTP_SENDING.md

@dreamhunter2333 dreamhunter2333 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

开发者 Review / Developer review

谢谢补充 SMTP 发送教程。不过这份文档现在不能直接合并,主要原因是位置和语言结构不符合项目文档体系。

需要调整:

  1. 请不要新增根目录 docs/SMTP_SENDING.md。当前项目文档站使用 VitePress,实际文档位于 vitepress-docs/docs/{zh,en}/...,根目录 docs/ 不会进入文档站导航,也不会被现有文档部署流程正确展示。
  2. 请把内容拆到现有正确位置,并保持中英文双语:
    • SMTP 配置、Cloudflare Dashboard / CLI secrets、provider recipes:放到 vitepress-docs/docs/zh/guide/config-send-mail.mdvitepress-docs/docs/en/guide/config-send-mail.md
    • HTTP /api/send_mail / /external/api/send_mail curl 示例:放到 vitepress-docs/docs/zh/guide/feature/send-mail-api.mdvitepress-docs/docs/en/guide/feature/send-mail-api.md
    • 常见错误排查:补充到 vitepress-docs/docs/zh/guide/common-issues.mdvitepress-docs/docs/en/guide/common-issues.md
  3. 如果你想保留一篇独立的 beginner tutorial,也需要创建成 VitePress 双语页面,例如 vitepress-docs/docs/zh/guide/... + vitepress-docs/docs/en/guide/...,并同步更新 vitepress-docs/docs/.vitepress/zh.tsvitepress-docs/docs/.vitepress/en.ts 的 sidebar。
  4. 请顺手补充 CHANGELOG.mdCHANGELOG_EN.md 当前 v1.10.0(main) 下的 docs entry。

English:

Thanks for adding the SMTP sending guide. This cannot be merged as-is because the file is outside the project documentation structure and only adds an English page.

Requested changes:

  1. Please do not add docs/SMTP_SENDING.md at the repository root. This project serves docs from VitePress under vitepress-docs/docs/{zh,en}/...; the root docs/ file will not appear in the docs site/navigation or the current deployment flow.
  2. Please move/split the content into the existing bilingual VitePress pages:
    • SMTP configuration, Dashboard / CLI secrets, and provider recipes: vitepress-docs/docs/zh/guide/config-send-mail.md and vitepress-docs/docs/en/guide/config-send-mail.md
    • HTTP /api/send_mail / /external/api/send_mail curl examples: vitepress-docs/docs/zh/guide/feature/send-mail-api.md and vitepress-docs/docs/en/guide/feature/send-mail-api.md
    • Common errors and troubleshooting: vitepress-docs/docs/zh/guide/common-issues.md and vitepress-docs/docs/en/guide/common-issues.md
  3. If you prefer a standalone beginner tutorial, it still needs paired VitePress pages under vitepress-docs/docs/zh/guide/... and vitepress-docs/docs/en/guide/..., plus matching sidebar entries in vitepress-docs/docs/.vitepress/zh.ts and vitepress-docs/docs/.vitepress/en.ts.
  4. Please also add a docs entry to the current v1.10.0(main) sections in both CHANGELOG.md and CHANGELOG_EN.md.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@vitepress-docs/docs/en/guide/config-send-mail.md`:
- Line 83: The fallback order description is inaccurate: the verified address
list is a short-circuit check, not a late fallback. Update the text in the docs
section that describes the mail-routing flow so it says the verified address
list is checked first and, if matched, the request goes through SEND_MAIL
immediately; only when it does not match should the logic continue to other
available channels such as SMTP, Resend, or the binding fallback. Keep the
wording aligned with the routing behavior described alongside SMTP_CONFIG and
SEND_MAIL.

In `@vitepress-docs/docs/zh/guide/config-send-mail.md`:
- Line 83: 文档中的回退顺序描述不准确,应先在相关说明里修正“已验证地址列表”的位置和行为:它不是最后兜底,而是优先短路判断,命中后会直接走
SEND_MAIL。请在该段落中结合 SMTP_CONFIG、smtpConfig 和 SEND_MAIL 的描述,改成“已验证地址列表优先判断;未命中后再按
SMTP、Resend、SEND_MAIL binding 等可用通道继续”,避免误导排障。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8db8483a-565c-4c04-bca3-8a3f837753eb

📥 Commits

Reviewing files that changed from the base of the PR and between 726e216 and 528db29.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • CHANGELOG_EN.md
  • vitepress-docs/docs/en/guide/common-issues.md
  • vitepress-docs/docs/en/guide/config-send-mail.md
  • vitepress-docs/docs/en/guide/feature/send-mail-api.md
  • vitepress-docs/docs/zh/guide/common-issues.md
  • vitepress-docs/docs/zh/guide/config-send-mail.md
  • vitepress-docs/docs/zh/guide/feature/send-mail-api.md
✅ Files skipped from review due to trivial changes (6)
  • CHANGELOG_EN.md
  • vitepress-docs/docs/zh/guide/common-issues.md
  • vitepress-docs/docs/zh/guide/feature/send-mail-api.md
  • vitepress-docs/docs/en/guide/feature/send-mail-api.md
  • vitepress-docs/docs/en/guide/common-issues.md
  • CHANGELOG.md

Comment thread vitepress-docs/docs/en/guide/config-send-mail.md Outdated
Comment thread vitepress-docs/docs/zh/guide/config-send-mail.md Outdated
dashitongzhi and others added 3 commits June 25, 2026 11:59
- Add docs/SMTP_SENDING.md with step-by-step SMTP configuration, app
  passwords, supported providers (Gmail / Outlook / custom), common
  errors and fixes, and 3 curl examples for sending mail via the
  Cloudflare email worker API
- References dreamhunter2333#609
@dashitongzhi
dashitongzhi force-pushed the docs/smtp-sending-tutorial-20260613090754 branch from 528db29 to 76dc332 Compare June 25, 2026 03:59
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.

能否在小白版教程后面,出一个关于发送邮件、SMTP的具体操作?

3 participants