Community生产力与协作github.com

resend/resend-cli

通过终端操作 Resend 平台 — 使用 `resend` CLI 发送邮件(包括 React Email .tsx 模板,通过 --react-email 参数)、管理域名、联系人、广播、模板、Webhook、API 密钥、日志、自动化和事件。推荐在用户需要在 Shell、脚本或 CI/CD 管道中执行 Resend 命令,或发送/预览 React Email 模板时使用。在执行 `resend` 命令前务必加载此技能 — 内含非交互式标志契约和防止静默失败的注意事项。

resend-cli 是什么?

该技能为 `resend` 命令行工具提供了全面的操作指南,使用户能够通过终端直接管理 Resend 平台的各项功能。其核心用途包括发送邮件(支持 React Email 的 .tsx 模板,通过 `--react-email` 参数)、管理域名、联系人、广播、模板、Webhook、API 密钥、日志、自动化规则和事件。该技能特别适合集成到 Shell 脚本、CI/CD 管道(如 GitHub Actions、GitLab CI)中,实现自动化邮件发送和平台管理。关键注意事项包括:所有命令都支持 `--json` 和 `--no-color` 等非交互式标志,以便于程序化处理;部分功能(如广播和自动化)有特定的操作步骤和静默失败风险(例如,广播需要先创建受众和联系人才能成功发送)。此外,该技能还强调了在使用 React Email 模板时,必须指定 `--from`、`--to`、`--subject` 和 `--react-email` 参数,且模板路径应为绝对路径。平台支持方面,该 CLI 适用于 macOS、Linux 和 Windows(通过 WSL),需要 Node.js 16+ 环境。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/resend/resend-skills/tree/main/skills/resend-cli

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

resend-cli 是做什么的?

通过终端操作 Resend 平台 — 发送邮件(包括 React Email .tsx 模板,通过 --react-email 参数)、管理域名、联系人、广播、模板、Webhook、API 密钥、日志、自动化和事件,均通过 resend CLI 实现。当用户希望在 Shell、脚本或 CI/CD 管道中运行 Resend 命令,或发送/预览 React Email 模板时使用此技能。在执行 resend 命令前务必加载此技能 — 内含非交互式标志契约和防止静默失败的注意事项。

可用命令

所有命令均支持使用 --json 和 --no-color 标志以支持非交互式使用。

邮件

  • resend emails send --from "" --to "" --subject "" --text "" — 发送纯文本邮件
  • resend emails send --from "" --to "" --subject "" --react-email /absolute/path/to/template.tsx — 发送 React Email 模板。必须提供 --from、--to、--subject 和 --react-email。路径必须是绝对路径。
  • resend emails send --from "" --to "" --subject "" --html "<h1>Hello</h1>" — 发送 HTML 内容
  • resend emails send --help — 查看所有发送选项
  • resend emails list — 列出已发送邮件
  • resend emails get <id> — 获取邮件详情
  • resend emails cancel <id> — 取消计划发送的邮件

域名

  • resend domains list — 列出所有域名
  • resend domains add <name> --region us|eu — 添加域名
  • resend domains verify <id> — 触发验证
  • resend domains get <id> — 获取域名详情

受众

  • resend audiences list — 列出所有受众
  • resend audiences add <name> — 创建新受众
  • resend audiences get <id> — 获取受众详情
  • resend audiences remove <id> — 删除受众

联系人

  • resend contacts list --audience-id <id> — 列出受众下的联系人(需要 --audience-id)
  • resend contacts create --email [email protected] --audience-id <id> — 向受众添加联系人(需要 --audience-id,可选 --first-name、--last-name、--unsubscribed)
  • resend contacts get <id> — 获取联系人详情
  • resend contacts update <id> --unsubscribed true|false — 更新联系人订阅状态
  • resend contacts remove <id> — 删除联系人

广播

  • resend broadcasts list — 列出所有广播
  • resend broadcasts send --audience-id <id> --from "" --subject "" — 发送广播。需要先创建受众并添加联系人。支持 --react-email、--html、--text 等参数。
  • resend broadcasts get <id> — 获取广播详情

模板

  • resend templates list — 列出所有模板
  • resend templates add --name "Name" --subject "Subject" --html "<html>...</html>" — 创建模板
  • resend templates get <id> — 获取模板详情
  • resend templates update <id> --name "New Name" — 更新模板
  • resend templates remove <id> — 删除模板

Webhook

  • resend webhooks list — 列出所有 Webhook
  • resend webhooks add --url https://example.com/hook --events email.sent,email.delivered — 创建 Webhook
  • resend webhooks get <id> — 获取 Webhook 详情
  • resend webhooks update <id> --url https://new-url.com/hook — 更新 Webhook
  • resend webhooks remove <id> — 删除 Webhook

API 密钥

  • resend api-keys list — 列出所有 API 密钥
  • resend api-keys add --name "My Key" --permission full|sending — 创建 API 密钥(返回密钥值)
  • resend api-keys remove <id> — 删除 API 密钥

日志

  • resend logs list — 列出日志事件(支持 --type 过滤,如 email.sent、email.bounced)

自动化

  • resend automations list — 列出所有自动化规则
  • resend automations create --name "Welcome" --trigger created --action send-email --audience-id <id> — 创建自动化规则
  • resend automations get <id> — 获取自动化详情
  • resend automations remove <id> — 删除自动化规则

事件

  • resend events list — 列出所有可用事件
  • resend events get <id> — 获取事件详情

非交互式标志

所有命令均支持以下标志以支持在脚本和 CI/CD 中使用:

  • --json — 以 JSON 格式输出结果
  • --no-color — 禁用彩色输出

使用场景

  • 在 CI/CD(GitHub Actions、GitLab CI)中发送事务性邮件 — 使用 resend emails send 配合 --json 标志
  • 管理邮件基础设施 — 添加并验证域名,创建受众并管理联系人
  • 发送 React Email 模板预览 — 在开发或 CI 环境中使用 --react-email 标志
  • 通过广播进行营销活动 — 先创建受众,添加联系人,然后发送广播
  • 设置自动化工作流 — 定义基于事件的自动化规则
  • 监控邮件传递状态 — 查询日志和事件以跟踪发送状态

静默失败注意事项

  • 广播发送失败 — 发送广播前,确认受众已存在且包含至少一个未退订的联系人。如果受众为空,广播会静默失败。
  • React Email 模板路径 — 必须使用绝对路径。相对路径会导致静默失败。
  • 联系人订阅状态 — 创建联系人时默认未退订。如果 --unsubscribed 设为 true,广播将不会发送给他们。
  • API 密钥权限 — 创建 API 密钥时,密钥值仅在创建时显示一次。如果丢失,需重新创建。
  • 域名验证 — 域名添加后需验证。未验证的域名无法发送邮件,但命令仍会返回成功。

环境要求

  • 需要 Node.js 16 或更高版本
  • 通过 npm 全局安装:npm install -g resend-cli
  • 需要有效的 Resend API 密钥(可通过 resend api-keys add 创建)
  • 通过 RESEND_API_KEY 环境变量或 resend login 配置

示例

# 发送简单邮件
resend emails send --from "[email protected]" --to "[email protected]" --subject "Hello" --text "Welcome!"

# 发送 React Email 模板
resend emails send --from "[email protected]" --to "[email protected]" --subject "Hello" --react-email /home/user/emails/welcome.tsx --json

# 创建受众并添加联系人
resend audiences add "Newsletter Subscribers"
resend contacts create --email [email protected] --audience-id <audience_id>

# 发送广播
resend broadcasts send --audience-id <audience_id> --from "[email protected]" --subject "Monthly Update" --html "<h1>Hello</h1>"

# 使用 JSON 输出创建 API 密钥(用于脚本)
resend api-keys add --name "CI Key" --permission sending --json

故障排除

如果遇到问题:

  1. 验证 RESEND_API_KEY 环境变量已设置
  2. 检查 API 密钥权限是否足够(发送邮件需要 sending 权限)
  3. 确认域名已验证
  4. 对 React Email 模板使用绝对路径
  5. 在脚本中使用 --json 标志以更好地处理错误
  6. 查看日志:resend logs list --type email.bounced

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

resend/agent-email-inbox

Use when building any system where email content triggers actions — AI agent inboxes, automated support handlers, email-to-task pipelines, or any workflow processing untrusted inbound email. Always use this skill when the user wants to receive emails and act on them programmatically, even if they don't mention "agent" — the skill contains critical security patterns (sender allowlists, content filtering, sandboxed processing) that prevent untrusted email from controlling your system.

resend/email-best-practices

Use when building email features, emails going to spam, high bounce rates, setting up SPF/DKIM/DMARC authentication, implementing email capture, ensuring compliance (CAN-SPAM, GDPR, CASL), handling webhooks, retry logic, making emails accessible (alt text, headings, contrast, screen readers), or deciding transactional vs marketing.

resend/react-email

Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.

resend/resend

Use when working with the Resend email API — sending transactional emails (single or batch), receiving inbound emails via webhooks, managing email templates, tracking delivery events, managing domains, contacts, broadcasts, webhooks, API keys, automations, events, viewing API request logs, or setting up the Resend SDK. Always use this skill when the user mentions Resend, even for simple tasks like "send an email with Resend" — the skill contains critical gotchas (idempotency keys, webhook verification, template variable syntax) that prevent common production issues.

相关技能