Skip to content Skip to sidebar Skip to footer

Python Error Sending Mail With Amazon Ses With Aws Lambda

I am new to aws lambda. I am trying to send mail with aws ses with aws lambda, without any triggers. Here is my code import boto3 from botocore.exceptions import ClientError ses

Solution 1:

The Lambda function you're running this code in does not have permission to send messages using SES. You need to add the action ses:SendEmail to your basic-lambda-role IAM Role.

When you run the code locally you will be communicating with SES using your own developer credentials, which probably have higher permissions.

Solution 2:

It seems that the role you're using doesn't have the relevant policies regarding the SES service.

Step 1: Create a custom policy - For example: SES-SendEmail-Policy and provide it with the following JSON:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail",  <--- This is the action that was missing
            ],
            "Resource": "*"
        }
    ]
}

Step 2: Attach the SES-SendEmail-Policy to the basic-lambda-role role.

Post a Comment for "Python Error Sending Mail With Amazon Ses With Aws Lambda"