首页 > 解决方案 > 添加将所有电子邮件地址列入白名单以使用 AWS SES 发送电子邮件的功能?

问题描述

因此,当我尝试在 AWS lambda 函数中使用 AWS SES 发送电子邮件时出现此错误...

User `arn:aws:sts::xxx:assumed-role/lambdaRole' is not authorized to perform 
`ses:SendEmail' on resource `arn:aws:ses:eu-west-1:xxx:identity/john@yyy.io'

现在我可以通过将此行添加到 lambda 策略来解决这个问题:

- Effect: Allow
  Action:
    - "ses:SendEmail"
  Resource:
    - !Sub "arn:aws:ses:eu-west-1:xxx:identity/john@yyy.io"

但是我希望能够向任何电子邮件地址发送电子邮件,并且我不想每次需要向新电子邮件地址发送电子邮件时都必须将此行添加到策略中。

有什么办法可以在允许我向所有电子邮件地址发送电子邮件的策略中添加一些内容?

这是我使用 Java SES SDK 的 Kotlin 代码...

val request = SendEmailRequest()
            .withDestination(Destination().withToAddresses("john@yyy.io"))
            .withMessage(Message()
                    .withBody(Body()
                            .withHtml(Content()
                                    .withCharset("UTF-8").withData(emailBody)))
                    .withSubject(Content()
                            .withCharset("UTF-8").withData("...")))
            .withSource("jim@ggg.io)


    SES_CLIENT.sendEmail(request)

谢谢!

标签: amazon-web-servicesemailaws-lambdaamazon-ses

解决方案


推荐阅读