我有以下设置:
安装了boto3的Python Flask API。我创建了一个boto3客户端,如下所示:
client = boto3.client(
"ses",
region_name='eu-west-1',
aws_access_key_id='myAccessKeyID',
aws_secret_access_key='mySecretAccessKey'
)
然后我试着发送这样一封电子邮件:
try:
client.send_email(
Source='VerifiedSourceEmail',
Destination={
'ToAddresses': ['VerifiedRecipientEmail'],
'CcAddresses': [],
'BccAddresses': [],
},
Message={
'Subject': {'Data': 'Test'},
'Body': {'Text': {'Data': 'Test'},
}
except ClientError as e:
return {
'ErrorCode': e.response['Error']['Code'],
'ErrorMessage': e.response['Error']['Message'],
}
当我尝试这样做时,我得到:
ErrorCode: SignatureDoesNotMatch
ErrorMessage: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
在连接到S3桶时,我使用了完全相同的客户端创建过程:
client = boto3.client(
"s3",
region_name='eu-west-1',
aws_access_key_id='myS3AccessKeyID',
aws_secret_access_key='myS3SecretAccessKey'
)
…这个客户端工作得很好,我已经测试了两个获取,上传和删除没有错误。
我已经测试了直接在AWS上发送邮件,这是有效的。我做错了什么?
从这个答案
要提供的发送电子邮件的密钥不是"SMTP凭据";.这些键是可以检索的全局访问键http://docs.amazonwebservices.com/ses/latest/GettingStartedGuide/GetAccessIDs.html。