Search code examples
pythonamazon-web-servicesaws-lambdaamazon-ses

AWS SES - Listing email identities with AWS Lambda


I'm sending emails to verified identities in AWS SES with ASW Lambda without problems. Now I'm just trying to list verified identities and getting no response.

Here is my code:

import boto3
from botocore.exceptions import ClientError

def list_identities():
    ses = boto3.client('ses')
    response = ses.list_identities(
      IdentityType = 'EmailAddress',
      MaxItems=10
    )

def lambda_handler(event, context):
    # TODO implement
    print("Listing EMAILS:")
    list_identities()

In function log I see printed Listing email: and nothing else. Lambda function is invoked in same region as AWS SES.


Solution

  • You don't return anything from your function.

    Try this:

    import boto3
    
    
    def list_identities():
        ses = boto3.client('ses')
        response = ses.list_identities(
            IdentityType='EmailAddress',
            MaxItems=10
        )
        return response
    
    
    def lambda_handler(event, context):
        # TODO implement
        print("Listing EMAILS:")
        print(list_identities())