Skip to main content

发送测试邮件

使用已保存的企业邮箱配置向单个收件人发送测试邮件,可指定邮件模板。返回成功仅表示 SMTP 服务器已受理,不保证邮件进入收件箱。

  • Scope:admin.v1.mail-tests.execute
  • 权限项:企业邮箱测试(mail-tests)
  • 权限类型:执行
  • 接口:POST/api/openapi/v1/mail-tests

认证与请求头

使用应用 API Key 调用。当前接口只校验上方独立 Scope;读取、管理与执行权限互不隐含。
名称位置类型必填说明示例
Authorizationheaderstring是应用 API Key,使用 Bearer 方式传递。Bearer qwk_***
X-Request-Idheaderstring否可选的调用追踪标识;未传入时由服务端生成。req-20260831-001

请求参数

名称位置类型必填说明示例
Idempotency-Keyheaderstring必填幂等键,用于避免重复提交"<string>"
server_versionbodyinteger · int64必填Version returned by GET /mail-servers/current; the saved configuration must still match.1
template_idbodystring否An existing ID from GET /mail-templates. Omit together with template_version to use the fixed test message."qw_vpc_EMAIL_VERIFICATION_CODE"
template_versionbodyinteger · int64否Required when template_id is supplied. Use the saved template version; zero is valid for the default template.0
to_emailbodystring · email必填One test recipient; accepted means SMTP acceptance, not inbox delivery."developer@example.com"

请求示例

curl --request POST \
  --url 'https://dev-develop.dev-vpc.qwenwork.cn/api/openapi/v1/mail-tests' \
  --header 'Authorization: Bearer <API_KEY>' \
  --header 'Idempotency-Key: <UNIQUE_REQUEST_ID>' \
  --header 'Content-Type: application/json' \
  --data '{
  "server_version": 1,
  "template_id": "qw_vpc_EMAIL_VERIFICATION_CODE",
  "template_version": 0,
  "to_email": "developer@example.com"
}'

响应

200 Accepted by SMTP; inbox delivery is not guaranteed.
名称类型必填说明示例
atstring · date-time是测试时间"2026-08-27T10:00:00Z"
codestring是错误码"<string>"
server_versioninteger · int64是邮件服务器配置版本号0
statusstring是测试状态"unknown"
template_idstring否模板 ID"<string>"
{
  "at": "2026-09-14T10:00:00Z",
  "code": "",
  "server_version": 1,
  "status": "accepted",
  "template_id": "qw_vpc_EMAIL_VERIFICATION_CODE"
}
502 SMTP failed or acceptance is unknown; inspect details and do not automatically resend.
名称类型必填说明示例
codestring是错误码"<string>"
detailstring是错误说明"<string>"
detailsOpenapifacadeMailTestResult是测试结果详情-
errorstring是错误类型"<string>"

details 字段

以下必填性针对对象存在时的子字段;父对象可否省略或为 null,以上层字段表为准。
字段类型必填说明
atstring · date-time是测试时间
codestring是错误码
server_versioninteger · int64是邮件服务器配置版本号
statusstring是测试状态;可选值:unknown, accepted, failed
template_idstring否模板 ID
{
  "code": "mail_test_submission_failed",
  "detail": "SMTP test was not confirmed as accepted; do not automatically resend.",
  "details": {
    "at": "2026-09-14T10:00:00Z",
    "code": "acceptance_unknown",
    "server_version": 1,
    "status": "unknown",
    "template_id": "qw_vpc_EMAIL_VERIFICATION_CODE"
  },
  "error": "BadGateway"
}

default Flat business error

名称类型必填说明示例
codestring否Stable business error code"<string>"
detailstring是Human-readable error description"<string>"
detailsOpenapiErrorDetails否测试结果详情-
errorstring是Stable HTTP error type"<string>"

details 字段

以下必填性针对对象存在时的子字段;父对象可否省略或为 null,以上层字段表为准。
字段类型必填说明
fieldstring否校验失败的请求字段
reasonstring否校验失败的原因代码
suggestionstring否建议使用的规范化值
{
  "code": "<string>",
  "detail": "<string>",
  "details": {
    "field": "<string>",
    "reason": "<string>",
    "suggestion": "<string>"
  },
  "error": "<string>"
}