You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS CLI发送SES模板邮件报错:Template参数类型错误如何解决?

问题原因

你混淆了AWS SES的两个核心命令:

  • create-template:用于创建邮件模板,需要传入完整的Template对象(包含名称、主题、HTML/文本内容)
  • send-templated-email:用于使用已创建好的模板发送邮件,仅需指定模板名称,不需要传入完整的Template字典

你当前的错误是在send-templated-email命令中传入了仅适用于create-template的Template对象,导致参数类型不匹配。

正确操作步骤

步骤1:先创建邮件模板

使用你的temp.json文件,通过create-template命令创建模板:

aws ses create-template --cli-input-json file://temp.json

步骤2:使用模板发送邮件

有两种写法可选:

写法1:纯命令行参数

直接指定所有必要参数,无需额外JSON文件:

aws ses send-templated-email \
  --source "temp@gmail.com" \
  --destination "ToAddresses=example@gmail.com" \
  --template "temp" \
  --template-data '{ "firstName": "temp", "lastName": "temp" }'

写法2:使用CLI输入JSON文件

创建一个新的JSON文件(比如send-email.json),内容如下:

{
  "Source": "temp@gmail.com",
  "Destination": {
    "ToAddresses": ["example@gmail.com"]
  },
  "Template": "temp",
  "TemplateData": "{ \"firstName\": \"temp\", \"lastName\": \"temp\" }"
}

然后执行命令:

aws ses send-templated-email --cli-input-json file://send-email.json
注意事项
  • 确保source中的邮箱地址已经在AWS SES中完成验证,否则邮件无法发送
  • 模板创建后可以重复使用,无需每次发送都重新创建

内容的提问来源于stack exchange,提问作者Moti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 06:06:19