Skip to content

查看邮件列表 ​

http
GET /api/mails?limit=3&toDomain=example.com
X-Admin-Key: your-admin-key

查询参数 ​

参数类型必填说明
limitnumber否每页数量,默认 3,范围 1-20
cursorstring否下一页游标,使用上次返回的 pagination.nextCursor
fromstring否按发件邮箱精确筛选
tostring否按收件邮箱精确筛选
toDomainstring否按收件域名精确筛选
subjectstring否按主题全文检索
contentstring否按正文全文检索
hasAttachmentsboolean否是否只看带附件邮件,仅支持 true 或 false
includeAttachmentsboolean否是否返回附件元信息,默认不返回;需要下载附件时设为 true

默认返回示例 ​

json
{
  "ok": true,
  "data": [
    {
      "id": "mail_abc123",
      "from": "sender@example.com",
      "fromName": "Sender",
      "to": "user@example.com",
      "toDomain": "example.com",
      "subject": "Invoice May",
      "preview": "Your invoice is ready",
      "text": "Your invoice is ready.",
      "html": "<p>Your invoice is ready.</p>",
      "hasAttachments": true,
      "attachmentCount": 1,
      "size": 188000,
      "receivedAt": "2026-05-06T10:00:00.000Z"
    }
  ],
  "pagination": {
    "limit": 3,
    "nextCursor": "eyJyZWNlaXZlZEF0IjoiMjAyNi0wNS0wNlQxMDowMDowMC4wMDBaIiwiaWQiOiJtYWlsX2FiYzEyMyJ9",
    "hasMore": true
  }
}

带 includeAttachments=true 时,邮件对象会额外返回 attachments:

json
{
  "id": "mail_abc123",
  "hasAttachments": true,
  "attachmentCount": 1,
  "attachments": [
    {
      "id": "att_abc123",
      "filename": "invoice.pdf",
      "mimeType": "application/pdf",
      "size": 102400,
      "contentId": "",
      "disposition": "attachment",
      "stored": true
    }
  ]
}

邮件字段 ​

字段类型说明
idstring邮件 ID,用于创建共享邮件和下载附件
fromstring发件邮箱
fromNamestring发件人显示名
tostring收件邮箱
toDomainstring收件域名
subjectstring主题
previewstring正文摘要
textstring纯文本正文
htmlstringHTML 正文
attachmentsarray附件元信息,仅 includeAttachments=true 时返回
hasAttachmentsboolean是否有附件
attachmentCountnumber附件数量
sizenumber原始邮件大小,单位字节
receivedAtstring接收时间,ISO 8601

附件字段 ​

字段类型说明
idstring附件 ID
filenamestring文件名
mimeTypestring文件 MIME 类型
sizenumber文件大小,单位字节
contentIdstring内联附件 Content-ID,没有则为空
dispositionstringattachment 或 inline
storedboolean是否已保存到 R2;只有 true 才能下载

公开接口没有单封邮件详情接口,列表接口已经返回正文。附件元信息默认不返回,需要下载附件时使用 includeAttachments=true 获取附件 ID。

Released under the MIT License.