recoup-platform-email-helper
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSending email from a task
从任务中发送邮件
Send email by running the bundled Node script — do not assemble JSON in the shell.
通过运行内置的Node脚本发送邮件——请勿在shell中手动组装JSON。
Why this exists
为什么需要这个工具
Hand-rolling the send () is fragile: depending on quoting/escaping it produces a malformed body, and the API used to silently deliver an empty footer-only email titled "Message from Recoup" with . The model gets this wrong stochastically. This script removes shell serialization entirely.
curl -sS … -d "{… \"html\": $(echo "$HTML" | jq -R -s '.') …}"success:true手动构建发送命令()很不稳定:根据引号/转义方式的不同,可能会生成格式错误的邮件内容,而API过去会静默发送仅包含页脚的空邮件,标题为**"Message from Recoup"**,同时返回。这种错误是随机出现的。本脚本彻底避免了shell序列化的问题。
curl -sS … -d "{… \"html\": $(echo "$HTML" | jq -R -s '.') …}"success:trueHow to send
如何发送邮件
-
Write the email body to a file (recommended for HTML — avoids all escaping issues):bash
cat > /tmp/report.html <<'HTML' <h1>Daily Report</h1> <p>…your real content…</p> HTML -
Send it:bash
node "$SKILL_DIR/scripts/send-email.mjs" \ --subject "Daily Report — $(date '+%B %d, %Y')" \ --html-file /tmp/report.html \ --to owner@example.com
$SKILL_DIR~/.agents/skills/recoup-platform-email-helperscripts/send-email.mjs-
将邮件内容写入文件(推荐用于HTML内容——可避免所有转义问题):bash
cat > /tmp/report.html <<'HTML' <h1>Daily Report</h1> <p>…your real content…</p> HTML -
发送邮件:bash
node "$SKILL_DIR/scripts/send-email.mjs" \ --subject "Daily Report — $(date '+%B %d, %Y')" \ --html-file /tmp/report.html \ --to owner@example.com
$SKILL_DIR~/.agents/skills/recoup-platform-email-helperscripts/send-email.mjsFlags
参数说明
| Flag | Meaning |
|---|---|
| Subject line (optional — the API derives one from the body if omitted). |
| HTML body. Prefer |
| Plain-text body. |
| Recipient (repeatable). Omit to default to the account's own email ("email me this"). |
| CC (repeatable). |
| Room id for the footer "continue the conversation" link. |
| Serialize + validate and print the payload; do not send. Use to preview. |
| 参数 | 含义 |
|---|---|
| 邮件主题(可选——若省略,API会从邮件内容中自动生成主题)。 |
| HTML格式的邮件内容。优先使用 |
| 纯文本格式的邮件内容。 |
| 收件人(可重复指定)。若省略,默认发送至账户自身邮箱(即“发送给我”)。 |
| 抄送收件人(可重复指定)。 |
| 页脚“继续对话”链接对应的房间ID。 |
| 序列化并验证请求 payload,仅打印内容;不实际发送邮件。用于预览效果。 |
Rules
规则
- Exactly one body is required. The script refuses to send (exit code 2) if there is no non-empty /
--html. Never try to send an empty email.--text - Check the exit code. Non-zero means it did not send — read stderr and fix it; do not report success. The script prints the Resend message id on a real send.
- The script reads /
RECOUP_API_KEYandRECOUP_ACCESS_TOKENfrom the environment — these are already set in the sandbox. Never print or hard-code them.RECOUP_API_BASE - Node only (the sandbox runtime is ;
node22is not guaranteed). Zero dependencies.python3
- 必须提供至少一种邮件内容。如果没有非空的/
--html,脚本会拒绝发送(退出码为2)。切勿尝试发送空邮件。--text - 检查退出码。非零值表示邮件未发送——请读取stderr输出并修复问题;不要误报发送成功。实际发送成功时,脚本会打印Resend消息ID。
- 脚本会从环境变量中读取/
RECOUP_API_KEY和RECOUP_ACCESS_TOKEN——这些变量在沙箱环境中已配置完成。切勿打印或硬编码这些值。RECOUP_API_BASE - 仅支持Node环境(沙箱运行时为;不保证
node22可用)。无依赖项。python3