无法在 AWS Lambda 上创建用于发送邮件的 boto ses 客户端
Not able to create boto ses client on AWS Lambda for sending mail
我的 python 代码无法在 Lambda 上运行,当我从我的本地 python 环境中 运行 它实际上运行良好时。每当我尝试在 Lambda 函数上创建 SES 对象时,我都会收到此错误:
Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
这是我的代码:
def lambda_handler(event, context):
connection = boto.ses.connect_to_region('us-east-1')
return connection.send_email(
from_addr,
subject,
None,
to,
format= format,
text_body=text,
html_body=html
)
这是否与 boto.ses
不支持 lambda 而我必须改用 boto3 有关?
这个 lambda 函数包含多个部分,最后我必须创建 SES 对象来向我的客户端发送邮件,但是当我尝试这样做时我收到了这个错误
这几天,强烈推荐使用boto3
。
语法是:
import boto3
connection = boto3.client('ses', region_name='us-east-1')
response = client.send_email(
Source='string',
Destination={
'ToAddresses': [
'string',
],
'CcAddresses': [
'string',
],
'BccAddresses': [
'string',
]
},
Message={
'Subject': {
'Data': 'string',
'Charset': 'string'
},
'Body': {
'Text': {
'Data': 'string',
'Charset': 'string'
},
'Html': {
'Data': 'string',
'Charset': 'string'
}
}
},
ReplyToAddresses=[
'string',
],
ReturnPath='string',
SourceArn='string',
ReturnPathArn='string',
Tags=[
{
'Name': 'string',
'Value': 'string'
},
],
ConfigurationSetName='string'
)
我的 python 代码无法在 Lambda 上运行,当我从我的本地 python 环境中 运行 它实际上运行良好时。每当我尝试在 Lambda 函数上创建 SES 对象时,我都会收到此错误:
Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
这是我的代码:
def lambda_handler(event, context):
connection = boto.ses.connect_to_region('us-east-1')
return connection.send_email(
from_addr,
subject,
None,
to,
format= format,
text_body=text,
html_body=html
)
这是否与 boto.ses
不支持 lambda 而我必须改用 boto3 有关?
这个 lambda 函数包含多个部分,最后我必须创建 SES 对象来向我的客户端发送邮件,但是当我尝试这样做时我收到了这个错误
这几天,强烈推荐使用boto3
。
语法是:
import boto3
connection = boto3.client('ses', region_name='us-east-1')
response = client.send_email(
Source='string',
Destination={
'ToAddresses': [
'string',
],
'CcAddresses': [
'string',
],
'BccAddresses': [
'string',
]
},
Message={
'Subject': {
'Data': 'string',
'Charset': 'string'
},
'Body': {
'Text': {
'Data': 'string',
'Charset': 'string'
},
'Html': {
'Data': 'string',
'Charset': 'string'
}
}
},
ReplyToAddresses=[
'string',
],
ReturnPath='string',
SourceArn='string',
ReturnPathArn='string',
Tags=[
{
'Name': 'string',
'Value': 'string'
},
],
ConfigurationSetName='string'
)