api:mk_ShSz32UZRlN4UBGZ36uAKpe9rvuK1SYc。

好的,以下是针对 MoeMail 邮箱系统 的 API 调用文档,包含 接收邮件(通过 MoeMail API)和 发送邮件(通过 Resend API)的完整示例。

请将文档中的 YOUR_MOEMAIL_API_KEY 替换为您的 MoeMail API Key(以 mk_ 开头),YOUR_RESEND_API_KEY 替换为您的 Resend API Key(re_9hsAtxAs_M8UAiX5Pn5S1BYuqqMydAMkZ)。


https://www.nullmail.cc/

3773246038

📬 MoeMail 邮箱 API 调用指南

准备

用途API Key 来源示例值
接收邮件(管理临时邮箱、读取邮件)MoeMail 后台 → API Key 管理mk_-Bwkn8szX1FvS2FxusIYY1jxFnNyMZU_
发送邮件Resend Dashboard → API Keysre_9hsAtxAs_M8UAiX5Pn5S1BYuqqMydAMkZ

一、接收邮件(MoeMail API)

1. 获取系统配置(查看可用域名)

Bash
curl https://mail.zhl2010.ccwu.cc/api/config \
  -H "X-API-Key: YOUR_MOEMAIL_API_KEY"

返回示例:

JSON
{
  "domains": ["zhl2010.ccwu.cc"],
  "maxEmailsPerUser": 100
}

2. 生成临时邮箱地址

Bash
curl -X POST https://mail.zhl2010.ccwu.cc/api/emails/generate \
  -H "X-API-Key: YOUR_MOEMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "myapi",
    "expiryTime": 3600000,
    "domain": "zhl2010.ccwu.cc"
  }'

参数说明:

  • name: 邮箱用户名(如 myapi → 完整地址 [email protected])
  • expiryTime: 有效期毫秒(3600000=1小时,86400000=1天,604800000=7天,0=永久)
  • domain: 域名,必须与 /api/config 返回的列表一致

返回示例:

JSON
{
  "id": "email_abc123",
  "email": "[email protected]",
  "expiresAt": 1734567890000
}

3. 获取所有临时邮箱列表

Bash
curl "https://mail.zhl2010.ccwu.cc/api/emails?cursor=" \
  -H "X-API-Key: YOUR_MOEMAIL_API_KEY"

分页: 响应中会返回 nextCursor,下次请求时替换 cursor= 参数。

4. 获取某个邮箱的邮件列表

Bash
curl "https://mail.zhl2010.ccwu.cc/api/emails/email_abc123?cursor=" \
  -H "X-API-Key: YOUR_MOEMAIL_API_KEY"

5. 读取单封邮件内容

Bash
curl https://mail.zhl2010.ccwu.cc/api/emails/email_abc123/message_xyz789 \
  -H "X-API-Key: YOUR_MOEMAIL_API_KEY"

二、发送邮件(Resend API)

MoeMail 本身不提供发信 API,请直接调用 Resend API(与 MoeMail 网页发信使用相同服务)。

Windows PowerShell

powershell
$resendKey = "re_9hsAtxAs_M8UAiX5Pn5S1BYuqqMydAMkZ"
curl.exe -X POST https://api.resend.com/emails `
  -H "Authorization: Bearer $resendKey" `
  -H "Content-Type: application/json" `
  -d '{
    "from": "[email protected]",
    "to": ["[email protected]"],
    "subject": "Hello from MoeMail API",
    "html": "<p>This is a test email sent via Resend API.</p>"
  }'

Linux / macOS 终端

Bash
curl -X POST https://api.resend.com/emails \
  -H "Authorization: Bearer re_9hsAtxAs_M8UAiX5Pn5S1BYuqqMydAMkZ" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "[email protected]",
    "to": ["[email protected]"],
    "subject": "Hello from MoeMail API",
    "html": "<p>This is a test email sent via Resend API.</p>"
  }'

参数说明:

  • from: 发件人地址,必须使用已验证的域名(zhl2010.ccwu.cc 或 mail.zhl2010.ccwu.cc)
  • to: 收件人数组,最多可填多个
  • subject: 邮件主题
  • html: 邮件正文(HTML 格式)
  • 还可选 text 纯文本版本、cc、bcc 等

成功返回示例:

JSON
{
  "id": "7050131e-e5f1-4e97-a897-7f9dcc432fca"
}

三、完整收发示例(PowerShell)

powershell
# 设置 API Keys
$moemailKey = "mk_-Bwkn8szX1FvS2FxusIYY1jxFnNyMZU_"
$resendKey   = "re_9hsAtxAs_M8UAiX5Pn5S1BYuqqMydAMkZ"

# 1. 创建一个临时邮箱
$generateBody = @{
    name = "apitest"
    expiryTime = 3600000
    domain = "zhl2010.ccwu.cc"
} | ConvertTo-Json
$emailResp = curl.exe -X POST https://mail.zhl2010.ccwu.cc/api/emails/generate `
    -H "X-API-Key: $moemailKey" `
    -H "Content-Type: application/json" `
    -d $generateBody
$emailId = ($emailResp | ConvertFrom-Json).id
Write-Host "Created email ID: $emailId"

# 2. 发送一封邮件到刚创建的临时邮箱(发给自己测试)
$sendBody = @{
    from = "[email protected]"
    to = @("[email protected]")
    subject = "Test from script"
    html = "<b>Hello</b>"
} | ConvertTo-Json
curl.exe -X POST https://api.resend.com/emails `
    -H "Authorization: Bearer $resendKey" `
    -H "Content-Type: application/json" `
    -d $sendBody

# 3. 等待几秒后查询邮件列表
Start-Sleep -Seconds 5
curl.exe "https://mail.zhl2010.ccwu.cc/api/emails/$emailId?cursor=" `
    -H "X-API-Key: $moemailKey"

四、注意事项

  1. MoeMail API Key 拥有您账户的全部权限,请妥善保管,不要公开分享。
  2. Resend API Key 仅用于发送邮件,同样需要保密。
  3. 发送邮件时,from 地址必须使用已在 Resend 中验证的域名(您的 zhl2010.ccwu.cc 已验证)。
  4. 接收邮件依赖于 Cloudflare Email Routing 正确配置(您已配置 * → email-receiver-worker)。
  5. 所有 MoeMail API 请求必须包含 X-API-Key 请求头;所有 Resend API 请求必须包含 Authorization: Bearer 头。

如果执行过程中遇到任何错误,请将完整的错误输出粘贴给我,我会帮您排查。