# 按模板发送邮件

# 简要描述
  • 使用商户在管控台(Web / App)配置的邮件模板发送邮件
  • 需先配置自定义 SMTP(邮件设置),再创建邮件模板
  • 添加模板时可选用内置系统模板(验证码 / 注册欢迎 / 重置密码 / 订单通知 / 登录通知)填入表单,再按需修改后保存
  • 模板内容类型:html(默认,按 text/html 发送)或 txt(按 text/plain 发送),在管控台创建/编辑时选择
  • 模板标题 / 正文支持 {0} {1} … 占位符,调用时通过 params 传参替换
  • 管控台支持对当前模板内容做预览(按 html / txt 渲染)
  • 禁止用于非法用途(如钓鱼等),一经发现严惩
# 请求URL
  • /api/sendEmailByTemplate
# 请求头
参数名 必选 类型 说明
Content-Type 是 string application/x-www-form-urlencoded 或 application/json
askKey 是 string 应用令牌
sign 否 string 开启验签时必传
time 否 string 开启验签时必传
apiUserToken 否 string 用户令牌
nonce 否 string V3验签时必传
# 请求方式
  • post
# 参数
参数名 必选 类型 说明
email 是 string 收件人邮箱
templateKey 是 string 模板 KEY(与管控台配置一致;也可用 key)
params 否 string/json 占位参数。支持 JSON 数组字符串如 ["张三","123456"],或逗号分隔 张三,123456
subject 否 string 可选,覆盖模板标题(覆盖后不再做占位替换)
# 请求示例
{
  "email": "user@example.com",
  "templateKey": "order_notify",
  "params": "[\"张三\",\"ORD2026001\"]"
}
1
2
3
4
5

纯文本验证码模板示例:

{
  "email": "user@example.com",
  "templateKey": "sys_verify_code",
  "params": "[\"123456\",\"5\"]"
}
1
2
3
4
5
# 返回示例
{
  "code": "200",
  "message": "",
  "status": true,
  "data": null,
  "pc": null
}
1
2
3
4
5
6
7
# 备注
  • 发送时邮件 MIME 类型由模板的 contentType(html / txt)决定,接口参数无需再传内容类型
  • 限流:同接口短时间过多调用会被限制(与 发送邮件 同类)
  • 发送成功会写入邮件记录(管控台「邮件记录」可查看 / 删除 / 批量删除)
  • 更多返回错误代码请查看 错误代码参考
lastUpdate: 10/15/2026, 3:34:23 PM