# 按模板发送邮件
# 简要描述
- 使用商户在管控台(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
# 参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| 是 | 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
2
3
4
5
纯文本验证码模板示例:
{
"email": "user@example.com",
"templateKey": "sys_verify_code",
"params": "[\"123456\",\"5\"]"
}
1
2
3
4
5
2
3
4
5
# 返回示例
{
"code": "200",
"message": "",
"status": true,
"data": null,
"pc": null
}
1
2
3
4
5
6
7
2
3
4
5
6
7