TempMail

API 文档

TempMail API v1 参考文档

基础地址

https://mail.taohuaxin.top

认证方式

所有接口(/config 除外)需要认证。

在所有请求中添加以下请求头:

x-api-key: tm_your_token_here

获取令牌:仪表盘 → 设置 → API 密钥

接口列表

方法路径说明
GET/api/v1/config服务器配置(公开 — 无需认证)
GET/api/v1/me跨所有邮箱获取邮件(长轮询)
GET/api/v1/inbox/:address获取单个邮箱的邮件(长轮询)
DELETE/api/v1/inbox/:address清空邮箱内所有邮件
GET/api/v1/email/:id获取完整邮件(文本 + HTML + 附件)
GET/api/v1/email/:id/rendered获取渲染后的邮件文本
GET/api/v1/email/:id/attachments/:attachmentId按附件 ID 下载单个附件
DELETE/api/v1/email/:id删除单封邮件
GET/api/v1/domains列出自定义域名
POST/api/v1/domains添加自定义域名
DELETE/api/v1/domains/:id删除自定义域名

docs.examples

GET/api/v1/config

服务器配置(公开 — 无需认证)

curl https://mail.taohuaxin.top/api/v1/config

docs.response

{
  "domains": ["taohuaxin.top"],
  "smtpPort": 25,
  "smtpsPort": 465,
  "mxPort": 25,
  "version": "1.0.0"
}
GET/api/v1/me

跨所有邮箱获取邮件(长轮询)

curl -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/me?count=1&limit=20"

docs.response

{
  "emails": [
    {
      "id": "cmcg2a1b40001xyz",
      "fromAddress": "[email protected]",
      "subject": "Your verification code",
      "isRead": false,
      "receivedAt": "2026-07-10T08:30:00.000Z",
      "mailbox": { "address": "alice", "domain": "taohuaxin.top" }
    }
  ],
  "nextSince": "cmcg2a1b40001xyz"
}
GET/api/v1/inbox/:address

获取单个邮箱的邮件(长轮询)

curl -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/inbox/[email protected]?since=cmcg2a1b40001xyz&count=1"

docs.response

{
  "emails": [
    {
      "id": "cmcg9f2c80002abc",
      "fromAddress": "[email protected]",
      "subject": "Welcome!",
      "isRead": false,
      "receivedAt": "2026-07-10T09:00:00.000Z"
    }
  ],
  "nextSince": "cmcg9f2c80002abc"
}
DELETE/api/v1/inbox/:address

清空邮箱内所有邮件

curl -X DELETE -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/inbox/[email protected]"

docs.response

{ "success": true }
GET/api/v1/email/:id

获取完整邮件(文本 + HTML + 附件)

curl -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/email/cmcg2a1b40001xyz"

docs.response

{
  "id": "cmcg2a1b40001xyz",
  "fromAddress": "[email protected]",
  "toAddress": "[email protected]",
  "subject": "Your verification code",
  "bodyHtml": "<p>Your code is <b>123456</b></p>",
  "bodyText": "Your code is 123456",
  "isRead": true,
  "receivedAt": "2026-07-10T08:30:00.000Z",
  "attachments": [
    { "id": "att_01", "filename": "invoice.pdf", "mimeType": "application/pdf", "size": 24580 }
  ]
}
GET/api/v1/email/:id/rendered

获取渲染后的邮件文本

curl -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/email/cmcg2a1b40001xyz/rendered"

docs.response

From: [email protected]
To: [email protected]
Subject: Your verification code
Date: Fri, 10 Jul 2026 08:30:00 GMT

<p>Your code is <b>123456</b></p>
GET/api/v1/email/:id/attachments/:attachmentId

按附件 ID 下载单个附件

curl -OJ -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/email/cmcg2a1b40001xyz/attachments/att_01"

docs.response

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="invoice.pdf"
Content-Length: 24580

<binary file stream>
DELETE/api/v1/email/:id

删除单封邮件

curl -X DELETE -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/email/cmcg2a1b40001xyz"

docs.response

{ "success": true }
GET/api/v1/domains

列出自定义域名

curl -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/domains"

docs.response

[
  {
    "id": "dom_01",
    "domain": "mail.example.com",
    "verified": true,
    "receiveMode": "inherit",
    "createdAt": "2026-07-01T00:00:00.000Z"
  }
]
POST/api/v1/domains

添加自定义域名

curl -X POST -H "x-api-key: tm_your_token_here" \
  -H "Content-Type: application/json" \
  -d '{"domain":"mail.example.com","receiveMode":"inherit"}' \
  "https://mail.taohuaxin.top/api/v1/domains"

docs.response

{
  "id": "dom_02",
  "domain": "mail.example.com",
  "verified": false,
  "receiveMode": "inherit",
  "createdAt": "2026-07-10T10:00:00.000Z"
}
DELETE/api/v1/domains/:id

删除自定义域名

curl -X DELETE -H "x-api-key: tm_your_token_here" \
  "https://mail.taohuaxin.top/api/v1/domains/dom_02"

docs.response

{ "success": true }

长轮询

收件箱接口支持长轮询。调用后服务器会阻塞等待邮件到达(最多 25 秒),超时返回 204。

查询参数

参数说明
since上次响应中的游标,只返回此之后的邮件
count累积 N 封新邮件后返回(默认 1,最大 50)
limit每次响应最多返回邮件数(默认 20,最大 50)
from过滤 — 只返回发件人包含此字符串的邮件
subject过滤 — 只返回主题包含此字符串的邮件

删除行为

所有 DELETE 操作均为软删除:用户不可见,管理员仍可审计查看。