recoup-platform-email-helper

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sending 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 (
curl -sS … -d "{… \"html\": $(echo "$HTML" | jq -R -s '.') …}"
) 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
success:true
. The model gets this wrong stochastically. This script removes shell serialization entirely.
手动构建发送命令(
curl -sS … -d "{… \"html\": $(echo "$HTML" | jq -R -s '.') …}"
)很不稳定:根据引号/转义方式的不同,可能会生成格式错误的邮件内容,而API过去会静默发送仅包含页脚的空邮件,标题为**"Message from Recoup"**,同时返回
success:true
。这种错误是随机出现的。本脚本彻底避免了shell序列化的问题。

How to send

如何发送邮件

  1. 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
  2. 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
is this skill's install directory (
~/.agents/skills/recoup-platform-email-helper
); use the absolute path to
scripts/send-email.mjs
.
  1. 将邮件内容写入文件(推荐用于HTML内容——可避免所有转义问题):
    bash
    cat > /tmp/report.html <<'HTML'
    <h1>Daily Report</h1>
    <p>…your real content…</p>
    HTML
  2. 发送邮件:
    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-helper
);请使用
scripts/send-email.mjs
的绝对路径。

Flags

参数说明

FlagMeaning
--subject <s>
Subject line (optional — the API derives one from the body if omitted).
--html-file <path>
/
--html <s>
HTML body. Prefer
--html-file
.
--text-file <path>
/
--text <s>
Plain-text body.
--to <email>
Recipient (repeatable). Omit to default to the account's own email ("email me this").
--cc <email>
CC (repeatable).
--chat-id <id>
Room id for the footer "continue the conversation" link.
--dry-run
Serialize + validate and print the payload; do not send. Use to preview.
参数含义
--subject <s>
邮件主题(可选——若省略,API会从邮件内容中自动生成主题)。
--html-file <path>
/
--html <s>
HTML格式的邮件内容。优先使用
--html-file
--text-file <path>
/
--text <s>
纯文本格式的邮件内容。
--to <email>
收件人(可重复指定)。若省略,默认发送至账户自身邮箱(即“发送给我”)。
--cc <email>
抄送收件人(可重复指定)。
--chat-id <id>
页脚“继续对话”链接对应的房间ID。
--dry-run
序列化并验证请求 payload,仅打印内容;不实际发送邮件。用于预览效果。

Rules

规则

  • Exactly one body is required. The script refuses to send (exit code 2) if there is no non-empty
    --html
    /
    --text
    . Never try to send an empty email.
  • 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_KEY
    /
    RECOUP_ACCESS_TOKEN
    and
    RECOUP_API_BASE
    from the environment — these are already set in the sandbox. Never print or hard-code them.
  • Node only (the sandbox runtime is
    node22
    ;
    python3
    is not guaranteed). Zero dependencies.
  • 必须提供至少一种邮件内容。如果没有非空的
    --html
    /
    --text
    ,脚本会拒绝发送(退出码为2)。切勿尝试发送空邮件。
  • 检查退出码。非零值表示邮件未发送——请读取stderr输出并修复问题;不要误报发送成功。实际发送成功时,脚本会打印Resend消息ID。
  • 脚本会从环境变量中读取
    RECOUP_API_KEY
    /
    RECOUP_ACCESS_TOKEN
    RECOUP_API_BASE
    ——这些变量在沙箱环境中已配置完成。切勿打印或硬编码这些值。
  • 仅支持Node环境(沙箱运行时为
    node22
    ;不保证
    python3
    可用)。无依赖项。