Skip to content

发送邮件

发送邮件需要先在系统设置中开启 Resend,并配置 Resend API Key。

http
POST /api/send
Content-Type: application/json
X-Admin-Key: your-admin-key

请求体

json
{
  "from": "[email protected]",
  "fromName": "DoneMail",
  "to": "[email protected]",
  "toName": "Receiver",
  "subject": "Hello",
  "text": "Plain text body",
  "html": "<p>HTML body</p>",
  "inReplyTo": "<[email protected]>",
  "references": "<[email protected]>",
  "attachments": [
    {
      "filename": "report.pdf",
      "mimeType": "application/pdf",
      "content": "base64-content"
    }
  ]
}

请求字段

字段类型必填说明
fromstring发件邮箱,域名必须已添加到 DoneMail 域名列表
fromNamestring发件人显示名
tostring收件邮箱
toNamestring收件人显示名
subjectstring邮件主题
textstring条件必填纯文本正文,texthtml 至少传一个
htmlstring条件必填HTML 正文,texthtml 至少传一个
inReplyTostring回复邮件时写入 In-Reply-To
referencesstring回复邮件时写入 References 头;不传时默认使用 inReplyTo
attachmentsarray附件列表,最多 10

附件字段

字段类型必填说明
filenamestring附件文件名
mimeTypestringMIME 类型,默认 application/octet-stream
contentstringBase64 内容,可带 data:*/*;base64, 前缀

附件限制

限制说明
单个附件最大 8MB
单封附件总大小最大 20MB
Resend 请求总大小最大 40MB
禁止类型.exe.bat.js.vbs.ps1 等高风险附件

成功返回

json
{
  "ok": true,
  "data": {
    "id": "sent_abc123",
    "status": "sent"
  }
}
字段类型说明
idstringDoneMail 发送记录 ID
statusstring固定为 sent

失败返回

json
{
  "ok": false,
  "error": {
    "code": "send_failed",
    "message": "发件域名不在本系统域名列表中"
  }
}
状态码code典型原因
400send_failedResend 未开启、API Key 未配置、邮箱格式错误、主题为空、正文为空、附件超限、发件域名未添加

Released under the MIT License.