通过 AWS CLI 使用 SES 发送 EC2 电子邮件

发布于 2025-01-17 03:21:52 字数 301 浏览 3 评论 0原文

我试图弄清楚是否有办法通过 AWS CLI 从 Linux EC2 实例发送 SES 电子邮件。我看了一些例子,说最好使用 SMTP,说 SES 可以工作,但没有详细说明,或者有些例子说这是不可能的。

我已经尝试过:

aws ses send-raw-email --from-arn arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<instance-id> --destinations <list>

但我什么也没得到。

I'm trying to figure out if there is a way to send an SES email from a Linux EC2 instance through AWS CLI. I looked at some examples saying that it's better to use SMTP, saying SES would work but no details behind, or some saying it's not possible.

I have tried this:

aws ses send-raw-email --from-arn arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<instance-id> --destinations <list>

but I didn't get anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是在用心讲痛 2025-01-24 03:21:52

根据 send-raw-email aws ses send-raw-email help 的帮助页面,参数 --from-arn已验证的资源名称您在 SES 中配置的身份。

该参数仅用于发送授权。它是与发送授权关联的身份的 ARN
允许您指定特定“发件人”地址的策略
原始电子邮件的标头。

更重要的是,它不是您调用 CLI 的 EC2 实例的 ARN。

考虑下面的示例:

  1. 没有参数 --from-arn,而是使用 --source
% aws ses send-raw-email --source [email protected] --destinations [email protected] --raw-message file://email.json --cli-binary-format raw-in-base64-out
{
    "MessageId": "0100017fc8dc8fbd-34f5bf83-ac26-4bd5-aa69-7358d96d925a-000000"
}
  1. 使用 --from-arn
% aws ses send-raw-email --from-arn arn:aws:ses:us-region-x:xxxxx:identity/[email protected] --destinations [email protected] --raw-message file://email.json --cli-binary-format raw-in-base64-out
{
    "MessageId": "0100017fc8df4fd7-3c21d871-3883-4d4c-8c82-17cbfd479e5f-000000"
}

在这两种情况下,SES已将电子邮件发送至指定目的地。

As per the help page of send-raw-email aws ses send-raw-email help, parameter --from-arn is the resource name of the verified identity you configure in SES.

This parameter is used only for sending authorization. It is the ARN of the identity that is associated with the sending authorization
policy that permits you to specify a particular "From" address in
the header of the raw email.

More importantly it is not the ARN of the EC2 instance from which you are invoking the CLI.

Consider the examples below:

  1. Without parameter --from-arn, instead using --source
% aws ses send-raw-email --source [email protected] --destinations [email protected] --raw-message file://email.json --cli-binary-format raw-in-base64-out
{
    "MessageId": "0100017fc8dc8fbd-34f5bf83-ac26-4bd5-aa69-7358d96d925a-000000"
}
  1. Using --from-arn
% aws ses send-raw-email --from-arn arn:aws:ses:us-region-x:xxxxx:identity/[email protected] --destinations [email protected] --raw-message file://email.json --cli-binary-format raw-in-base64-out
{
    "MessageId": "0100017fc8df4fd7-3c21d871-3883-4d4c-8c82-17cbfd479e5f-000000"
}

In both cases, SES sent email to the specified destination.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文