发送测试邮件
将 <BASE_URL> 替换为所在企业环境的 API 域名。
- Scope:
admin.v1.mail-tests.execute - 权限项:企业邮箱测试(
mail-tests) - 权限类型:执行
- 接口:POST
/api/openapi/v1/mail-tests
认证与请求头
使用应用 API Key 调用。当前接口只校验上方独立 Scope;读取、管理与执行权限互不隐含。
| 名称 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
Authorization | header | string | 是 | 应用 API Key,使用 Bearer 方式传递。 | Bearer qwk_*** |
X-Request-Id | header | string | 否 | 可选的调用追踪标识;未传入时由服务端生成。 | req-20260831-001 |
请求参数
| 名称 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
Idempotency-Key | header | string | 必填 | - | "<string>" |
server_version | body | integer · int64 | 必填 | Version returned by GET /mail-servers/current; the saved configuration must still match. | 1 |
template_id | body | string | 否 | An existing ID from GET /mail-templates. Omit together with template_version to use the fixed test message. | "qw_vpc_EMAIL_VERIFICATION_CODE" |
template_version | body | integer · int64 | 否 | Required when template_id is supplied. Use the saved template version; zero is valid for the default template. | 0 |
to_email | body | string · email | 必填 | One test recipient; accepted means SMTP acceptance, not inbox delivery. | "developer@example.com" |
请求示例
cURL
curl --request POST \
--url '<BASE_URL>/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.
| 名称 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
at | string · date-time | 是 | - | "2026-08-27T10:00:00Z" |
code | string | 是 | - | "<string>" |
server_version | integer · int64 | 是 | - | 0 |
status | string | 是 | - | "unknown" |
template_id | string | 否 | - | "<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.
| 名称 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
code | string | 是 | - | "<string>" |
detail | string | 是 | - | "<string>" |
details | OpenapifacadeMailTestResult | 是 | - | {"at":"2026-08-27T10:00:00Z","code":"<string>","server_version":0,"status":"unknown","template_id":"<string>"} |
details.at | string · date-time | 是 | - | "2026-08-27T10:00:00Z" |
details.code | string | 是 | - | "<string>" |
details.server_version | integer · int64 | 是 | - | 0 |
details.status | string | 是 | - | "unknown" |
details.template_id | string | 否 | - | "<string>" |
error | string | 是 | - | "<string>" |
响应示例
{
"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
| 名称 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
code | string | 否 | Stable business error code | "<string>" |
detail | string | 是 | Human-readable error description | "<string>" |
details | OpenapiErrorDetails | 否 | - | {"field":"<string>","reason":"<string>","suggestion":"<string>"} |
details.field | string | 否 | Request field that failed validation | "<string>" |
details.reason | string | 否 | Stable validation failure reason | "<string>" |
details.suggestion | string | 否 | Suggested normalized value | "<string>" |
error | string | 是 | Stable HTTP error type | "<string>" |
响应示例
{
"code": "<string>",
"detail": "<string>",
"details": {
"field": "<string>",
"reason": "<string>",
"suggestion": "<string>"
},
"error": "<string>"
}