TUNGKAO API 文档
📧
API · email

邮件发送 + OTP + SMTP

通过 API 或 SMTP 从网站发送邮件(支持 WordPress),并发送邮件 OTP 验证码及校验——自动在多家邮件服务商之间切换。

🕒 最近更新: 泰国时间(UTC+07:00) · ✅ 现有代码照常可用,无需修改

🤖 让 AI 帮你写对接代码

复制此链接给 AI 阅读(该 API 的完整 Markdown),或点击下方按钮:自动复制提示词并打开所选 AI,粘贴后告诉它你的语言/框架

https://app.tungkao.com/docs/api/email.md?lang=zh-CN
https://api.tungkao.com/changelog/email.json

此链接以 JSON 返回该 API 的更新(无需 key,任何域名可访问)。可在后台显示为“更新公告”框,last_updated 变化时标记“新”

复制并打开: 点击 AI 按钮会自动复制提示词,若对话框为空直接粘贴即可

🔑 使用的密钥

在商户后台(API key)创建 email 密钥,并在每个请求中发送此 header——其他服务的密钥在这里无效

Authorization: Bearer $TUNGKAO_KEY

📋 步骤

  1. 创建邮件密钥(测试密钥只能发到你自己的邮箱,每天 50 封)。
  2. SMTP:主机 smtp.tungkao.com,端口 587(STARTTLS)或 465(SSL),用户名任意,密码 = 你的 API 密钥。
  3. API:发送邮件,或申请 OTP 并用返回的 otp_id 校验(5 次机会,只能用一次)。

📡 接口调用 + 代码示例

POST/v1/email/send
curl -X POST https://api.tungkao.com/v1/email/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":["[email protected]"],"subject":"Order #1001 confirmed","html":"<h1>Thanks for your order</h1>","text":"Thanks for your order","from_name":"My Shop","reply_to":"[email protected]"}'
POST/v1/email/otp/send
curl -X POST https://api.tungkao.com/v1/email/otp/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"[email protected]","brand":"My Shop","lang":"th","length":6,"ttl_seconds":300}'
POST/v1/email/otp/verify
curl -X POST https://api.tungkao.com/v1/email/otp/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"otp_id":"8f6c2a1e-…","code":"123456"}'

📚 使用示例

示例 1

Order confirmation email

场景: A customer completes an order

请求
POST /v1/email/send
{
  "to": [
    "[email protected]"
  ],
  "subject": "Order #1001 confirmed",
  "html": "<h1>Thanks for your order</h1>",
  "text": "Thanks for your order",
  "from_name": "My Shop",
  "reply_to": "[email protected]"
}

➡️ Always send html and text; replies go to reply_to

示例 2

Send an email OTP

场景: A new sign-up must confirm their email

请求
POST /v1/email/otp/send
{
  "to": "[email protected]",
  "brand": "My Shop",
  "lang": "th",
  "length": 6,
  "ttl_seconds": 300
}
响应示例
{
  "success": true,
  "data": {
    "otp_id": "8f6c2a1e-…"
  }
}

➡️ Keep otp_id; the code expires in 5 minutes

示例 3

Check the OTP

场景: The user types the 6-digit code

请求
POST /v1/email/otp/verify
{
  "otp_id": "8f6c2a1e-…",
  "code": "123456"
}

➡️ Correct = email confirmed · too many wrong tries = code locked, send a new one

示例 4

Send to several people

场景: Tell three staff about a large order

请求
POST /v1/email/send
{
  "to": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "subject": "Large order #1002",
  "text": "Order #1002: 25,000 THB"
}

➡️ Everyone listed receives the email

示例 5

Review sent emails

场景: A customer says the email never arrived

请求
GET /v1/email/messages

➡️ Check the delivery status of each email

💡 更多

📜 此 API 的更新记录

  1. 新增 泰国时间(UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  2. 新增 泰国时间(UTC+07:00)
    error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
  3. 新增 泰国时间(UTC+07:00)
    GET /status:按服务显示 API 状态(无需密钥)
  4. 上线 泰国时间(UTC+07:00)
    上线邮件服务:API + SMTP(smtp.tungkao.com)+ 邮件 OTP
  5. 新增 泰国时间(UTC+07:00)
    密钥开关及状态变更时间 + 每个网站每项服务 1 个密钥
  6. 改进 泰国时间(UTC+07:00)
    API v1 永久冻结(仅新增)+ X-Tungkao-Api-Version header + 提前 12 个月的弃用通知
  7. 文档 泰国时间(UTC+07:00)
    每个 API 独立文档页及 AI 链接(10 种语言)
  8. 安全 泰国时间(UTC+07:00)
    每个 API 密钥域名验证(1 密钥 = 1 网站)——现有密钥照常可用
  9. 新增 泰国时间(UTC+07:00)
    可选 HMAC 请求签名——不开启则一切照旧
  10. 新增 泰国时间(UTC+07:00)
    API 密钥有效期、到期提醒和续期——密钥字符串不变
  11. 新增 泰国时间(UTC+07:00)
    所有服务支持 test 模式密钥(模拟、免费)

✅ 现有代码照常可用,无需修改

🛡️ 稳定性承诺:一次对接,长期可用

🚦 系统状态(GET /status)

随时查看 API 是否正常,无需密钥

GET https://api.tungkao.com/status

curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🏷️ TUNGKAO 署名要求

Powered by TUNGKAO