aws ses 自动化脚本:解析参数“--destination”时出错:预期:“=”,收到:“@”输入:

问题描述

我已经成为读者一段时间了。通常自己处理事情,但今天我需要一个提示

因此,我的任务是在我的新工作(10 万受众)中以最少的预算和很短的通知时间(明天)开展电子邮件活动。我倾向于 AWS(亚马逊网络服务),因为亚马逊 SES(简单电子邮件服务)非常便宜,而且您只需支付使用的费用。

尝试在命令行上使用 AWS SDK。我制作了一个小脚本来逐行读取地址文件 (.txt) 并执行发送邮件命令

#! /bin/bash

file='./test-list.txt'
from='sender@domain.com'

for line in $(<$file)
do
    #send mail
    aws ses send-templated-email --source=$from --destination=$line --template 'test' --template-data ""
done

脚本返回错误信息:

Error parsing parameter '--destination': Expected: '=',received: '@' for input:
To:recipient@domain.com

现在我不是 bash 之王,但我尝试了不同的参数公式,但没有任何方法可以消除错误。 输入文件中的每一行都是正确的电子邮件地址,这看起来像是解析问题,但我不明白。

有什么想法吗?这将有很大帮助:)

解决方法

您需要为 https://docs.aws.amazon.com/cli/latest/reference/ses/send-templated-email.html#options 中的目的地使用正确的格式

使用 send-email 的示例:

aws ses send-email --from "example.com" --destination "ToAddresses=${line}" --text "hello world!" --subject "test"

举个例子:

aws ses send-templated-email --source $from --destination "ToAddresses=${line}" --template "test" --template-data ""