繁体   English   中英

通过 python lambda 函数使用 boto3 的 AWS SES 电子邮件

[英]AWS SES Email using boto3 through python lambda function

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 目前仅在 3 个区域提供其 SES 服务:

  • 美国东部(弗吉尼亚us-east-1us-east-1
  • 美国西部(俄勒冈) us-west-2
  • 欧盟(爱尔兰) eu-west-1

使用上述之一作为您的AWS_REGION

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

问题由硬编码区域字符串'us-east-1' 解决

现在我将客户端创建为:

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM