簡體   English   中英

通過 AWS CLI 發送帶有 SES 的 EC2 email

[英]Send an EC2 email with SES through the AWS CLI

我試圖弄清楚是否有辦法通過 AWS CLI 從 Linux EC2 實例發送 SES email。 我看了一些例子,說最好使用 SMTP,說 SES 可以,但后面沒有細節,或者有些人說這是不可能的。

我試過這個:

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

但我什么也沒得到。

根據 send-raw-email aws ses send-raw-email help的幫助頁面,參數--from-arn是您在 SES 中配置的已驗證身份的資源名稱。

此參數僅用於發送授權。 它是與發送授權策略關聯的身份的 ARN,允許您在原始 email 的 header 中指定特定的“發件人”地址。


更重要的是,它不是您從中調用 CLI 的 EC2 實例的 ARN。

考慮以下示例:

  1. 沒有參數--from-arn ,而是使用--source
% aws ses send-raw-email --source saini001@gmail.com --destinations saini001@gmail.com --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/saini001@gmail.com --destinations saini001@gmail.com --raw-message file://email.json --cli-binary-format raw-in-base64-out
{
    "MessageId": "0100017fc8df4fd7-3c21d871-3883-4d4c-8c82-17cbfd479e5f-000000"
}

在這兩種情況下,SES 都會將 email 發送到指定的目的地。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM