【问题标题】:AWS SES Email using boto3 through python lambda function通过 python lambda 函数使用 boto3 的 AWS SES 电子邮件
【发布时间】:2018-11-14 12:12:25
【问题描述】:
boto3.client('ses').send_email(
        Source = email_from,
        Destination={
            'ToAddresses': [
                email_to,
            ]
        },
        Message={
            'Subject': {
                'Data': emaiL_subject
            },
            'Body': {
                'Text': {
                    'Data': email_body.format(user_password)
                }
            }
        }
    )

我正在使用 boto3 SES,通过 lambda 函数执行上述代码后,我收到以下错误:

Could not connect to the endpoint URL: \"https://email.ap-southeast-1.amazonaws.com/\

对于 Lambda 函数,我的区域是 ap-southeast-1

任何帮助都会被应用

【问题讨论】:

  • 您在 ~/.aws/config 的配置文件中有什么内容?
  • @Prany 我没有使用 ~/.aws/config。我正在将代码写入实时控制台

标签: python amazon-web-services aws-lambda boto3 amazon-ses


【解决方案1】:

AWS 目前仅在 6 个区域提供其 SES 服务:

  • 美国东部(弗吉尼亚北部)us-east-1
  • 美国西部(俄勒冈)us-west-2
  • 欧盟(爱尔兰)eu-west-1
  • 美联社(孟买)ap-south-1
  • 美联社(悉尼)ap-southeast-2
  • 欧盟(法兰克福)eu-central-1

使用上述之一作为您的AWS_REGION

client = boto3.client('ses',region_name=AWS_REGION)

注意:在 AWS website 上查找最新的区域列表。

【讨论】:

    【解决方案2】:

    问题已通过硬编码区域字符串 'us-east-1'

    解决

    现在我将客户端创建为:

    boto3.client('ses', 'us-east-1')
    

    我认为这是由于新加坡地区没有 SES。

    【讨论】:

      【解决方案3】:

      在使用之前,您始终可以在https://status.aws.amazon.com/ 上查看 AWS 服务的状态及其在不同区域的可用性。

      【讨论】:

        猜你喜欢
        • 2015-12-13
        • 2016-11-17
        • 2016-12-19
        • 2020-11-25
        • 1970-01-01
        • 2017-06-06
        • 1970-01-01
        • 1970-01-01
        • 2019-12-07
        相关资源
        最近更新 更多