从这里开始

快速入门

创建密钥、验证域名,并用一个可安全重试的请求发送一封受控的邮件。

开始之前

Create a SendHQ workspace and keep the dashboard open. New workspaces receive a controlled integration trial: deliveries can go only to the account email or a mailbox-simulator test address until a paid subscription is active.

1. 创建 API 密钥

在控制台中打开 API keys,填写一个描述性名称(例如 Production),并在密钥显示时将其复制。请将其保存在服务端的机密信息管理器中。SendHQ 不会再次返回完整的密钥值。

.env
SENDHQ_API_KEY=re_your_key_here

2. 添加发信域名

Open Domains, add a domain you control, and publish the returned DKIM, SPF, DMARC, and domain verification records. Cloudflare users can authorize a one-time DNS setup; SendHQ discards the OAuth token after the callback.

Do not publish a second SPF policy.If SPF already exists, merge SendHQ's SPF include (include:amazonses.com) into the existing v=spf1 value.

3. 等待验证

Use the dashboard or POST /domains/:id/verify. DNS can move through pending, checking, and propagating before the sending identity is verified.

4. 发送一封受控的邮件

curl
curl https://sendhq.cc/api/v1/emails \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: onboarding-user-42" \
  -d '{"from":"Acme <hello@example.com>","to":["owner@example.com"],"subject":"SendHQ is connected","html":"<h1>It works</h1><p>Your first controlled message was accepted.</p>","text":"It works. Your first controlled message was accepted."}'

请求成功后会返回 SendHQ 邮件 ID、服务商的邮件 ID 以及会话 ID。请将 SendHQ ID 与触发这封邮件的应用事件一起持久化保存。

5. 处理结果

API 请求被受理并不等于已投递给收件人。请获取 /emails/:id/events 或使用控制台,查看投递、退信、投诉、拒绝、打开和点击事件。