itecdn 5.x用户文档
itecdn 5.x / 用户 API

发送邮箱验证码

POST/v1/email-captcha

向指定邮箱发送 6 位验证码,用于注册、找回密码或邮箱验证。该公共接口不要求登录。收件人可由 account 指定的已启用账号解析,或直接由 email 指定;两种方式不能混用。系统会按 captcha_type.email 配置校验原生图形验证码、腾讯云验证码或极验验证码;同一客户端 IP 在 60 秒内最多成功发送一次。

身份认证

无需身份认证。

请求参数

参数位置类型必填说明与约束
codecookiestring可选

当系统邮箱验证码类型为 native 时必填。应携带先调用 GET /v1/common/captcha 时服务端写入的 code Cookie;该 Cookie 中的图形验证码约 60 秒失效。腾讯云或极验验证模式不使用此 Cookie。

完整参数定义
{
  "name": "code",
  "in": "cookie",
  "required": false,
  "description": "当系统邮箱验证码类型为 native 时必填。应携带先调用 GET /v1/common/captcha 时服务端写入的 code Cookie;该 Cookie 中的图形验证码约 60 秒失效。腾讯云或极验验证模式不使用此 Cookie。",
  "schema": {
    "type": "string",
    "example": "<encrypted-captcha-cookie>"
  }
}

请求体 · 必填

application/json

object

发送邮箱验证码的请求。account 存在时服务端忽略 email 和 check_exist,并按账号查询已启用用户的邮箱;否则 email 和 check_exist 均为必填。验证码平台字段由服务器的 captcha_type.email 配置决定。

字段类型必填说明与约束
accountstring可选

可选。已启用用户的邮箱、用户名或手机号;服务端据此取得该用户已配置的邮箱。提供时不能为空,且账号必须存在并已设置邮箱。

emailstring (email)可选

未提供 account 时必填。直接接收验证码的邮箱地址,必须为合法邮箱格式。

约束 / 默认值 / 示例
{
  "format": "email"
}
check_existinteger可选

未提供 account 时必填。邮箱存在性要求:0 表示邮箱必须不存在(通常用于注册);1 表示邮箱必须是已启用用户的邮箱(通常用于找回密码)。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
codestring可选

当 captcha_type.email 为 native 时必填。GET /v1/common/captcha 返回的图形验证码文本,按不区分大小写方式与 code Cookie 中的值比对;同一图形验证码一分钟内不能重复用于发送邮件。

ticketstring可选

当 captcha_type.email 为 qcloud 时必填。腾讯云验证码返回的票据。

randstrstring可选

当 captcha_type.email 为 qcloud 时必填。腾讯云验证码返回的随机字符串。

lot_numberstring可选

当 captcha_type.email 为 geetest 时必填。极验验证结果中的 lot_number。

captcha_outputstring可选

当 captcha_type.email 为 geetest 时必填。极验验证结果中的 captcha_output。

pass_tokenstring可选

当 captcha_type.email 为 geetest 时必填。极验验证结果中的 pass_token。

gen_timestring可选

当 captcha_type.email 为 geetest 时必填。极验验证结果中的 gen_time。

完整 Schema
{
  "type": "object",
  "description": "发送邮箱验证码的请求。account 存在时服务端忽略 email 和 check_exist,并按账号查询已启用用户的邮箱;否则 email 和 check_exist 均为必填。验证码平台字段由服务器的 captcha_type.email 配置决定。",
  "properties": {
    "account": {
      "type": "string",
      "description": "可选。已启用用户的邮箱、用户名或手机号;服务端据此取得该用户已配置的邮箱。提供时不能为空,且账号必须存在并已设置邮箱。"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "未提供 account 时必填。直接接收验证码的邮箱地址,必须为合法邮箱格式。"
    },
    "check_exist": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "未提供 account 时必填。邮箱存在性要求:0 表示邮箱必须不存在(通常用于注册);1 表示邮箱必须是已启用用户的邮箱(通常用于找回密码)。"
    },
    "code": {
      "type": "string",
      "description": "当 captcha_type.email 为 native 时必填。GET /v1/common/captcha 返回的图形验证码文本,按不区分大小写方式与 code Cookie 中的值比对;同一图形验证码一分钟内不能重复用于发送邮件。"
    },
    "ticket": {
      "type": "string",
      "description": "当 captcha_type.email 为 qcloud 时必填。腾讯云验证码返回的票据。"
    },
    "randstr": {
      "type": "string",
      "description": "当 captcha_type.email 为 qcloud 时必填。腾讯云验证码返回的随机字符串。"
    },
    "lot_number": {
      "type": "string",
      "description": "当 captcha_type.email 为 geetest 时必填。极验验证结果中的 lot_number。"
    },
    "captcha_output": {
      "type": "string",
      "description": "当 captcha_type.email 为 geetest 时必填。极验验证结果中的 captcha_output。"
    },
    "pass_token": {
      "type": "string",
      "description": "当 captcha_type.email 为 geetest 时必填。极验验证结果中的 pass_token。"
    },
    "gen_time": {
      "type": "string",
      "description": "当 captcha_type.email 为 geetest 时必填。极验验证结果中的 gen_time。"
    }
  },
  "additionalProperties": false
}

示例

{
  "email": "user@example.invalid",
  "check_exist": 0,
  "code": "a7Kp"
}

请求体示例

{
  "account": "string",
  "email": "user@example.com",
  "check_exist": 0,
  "code": "string",
  "ticket": "string",
  "randstr": "string",
  "lot_number": "string",
  "captcha_output": "string",
  "pass_token": "string",
  "gen_time": "string"
}

响应

HTTP 200

业务结果始终使用 HTTP 200 返回。发送成功时 data 为 null;参数、收件人、验证码平台校验、频率限制和邮件发送失败均在同一响应中以业务错误码表示。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

发送成功提示。

约束 / 默认值 / 示例
{
  "enum": [
    "发送成功!"
  ]
}
datastring必填

成功时为 null。

约束 / 默认值 / 示例
{
  "nullable": true
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

邮箱/账号、存在性要求、验证码平台参数或校验、60 秒发送频率限制、邮件投递失败对应的业务错误码。

约束 / 默认值 / 示例
{
  "enum": [
    "email_captcha-1",
    "email_captcha-2",
    "email_captcha-3",
    "email_captcha-4",
    "email_captcha-5",
    "email_captcha-6",
    "email_captcha-7",
    "email_captcha-8",
    "email_captcha-9",
    "email_captcha-10",
    "email_captcha-11",
    "email_captcha-12",
    "email_captcha-13",
    "email_captcha-14",
    "email_captcha-15",
    "email_captcha-16",
    "email_captcha-17",
    "email_captcha-18",
    "email_captcha-19",
    "email_captcha-20",
    "email_captcha-21",
    "email_captcha-22",
    "email_captcha-23",
    "email_captcha-24",
    "email_captcha-25",
    "email_captcha-26",
    "email_captcha-27",
    "email_captcha-28",
    "email_captcha-29",
    "email_captcha-30",
    "email_captcha-31",
    "email_captcha-32",
    "email_captcha-33",
    "email_captcha-34"
  ]
}
msgstring必填

具体错误原因,例如邮箱已存在、验证码错误、请等待 60 秒后再获取或邮件发送失败。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "成功状态码,固定为 0。"
        },
        "msg": {
          "type": "string",
          "enum": [
            "发送成功!"
          ],
          "description": "发送成功提示。"
        },
        "data": {
          "type": "string",
          "nullable": true,
          "description": "成功时为 null。"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "email_captcha-1",
            "email_captcha-2",
            "email_captcha-3",
            "email_captcha-4",
            "email_captcha-5",
            "email_captcha-6",
            "email_captcha-7",
            "email_captcha-8",
            "email_captcha-9",
            "email_captcha-10",
            "email_captcha-11",
            "email_captcha-12",
            "email_captcha-13",
            "email_captcha-14",
            "email_captcha-15",
            "email_captcha-16",
            "email_captcha-17",
            "email_captcha-18",
            "email_captcha-19",
            "email_captcha-20",
            "email_captcha-21",
            "email_captcha-22",
            "email_captcha-23",
            "email_captcha-24",
            "email_captcha-25",
            "email_captcha-26",
            "email_captcha-27",
            "email_captcha-28",
            "email_captcha-29",
            "email_captcha-30",
            "email_captcha-31",
            "email_captcha-32",
            "email_captcha-33",
            "email_captcha-34"
          ],
          "description": "邮箱/账号、存在性要求、验证码平台参数或校验、60 秒发送频率限制、邮件投递失败对应的业务错误码。"
        },
        "msg": {
          "type": "string",
          "description": "具体错误原因,例如邮箱已存在、验证码错误、请等待 60 秒后再获取或邮件发送失败。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "msg": "发送成功!",
  "data": null
}

发送成功

{
  "code": 0,
  "msg": "发送成功!",
  "data": null
}

发送频率受限

{
  "code": "email_captcha-4",
  "msg": "请等待60秒后再重获",
  "data": ""
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request POST \
  "https://master.example.invalid/v1/email-captcha" \
  --header "Content-Type: application/json" \
  --data '{"account": "string", "email": "user@example.com", "check_exist": 0, "code": "string", "ticket": "string", "randstr": "string", "lot_number": "string", "captcha_output": "string", "pass_token": "string", "gen_time": "string"}'

查看完整接口 JSON