I want to share a little exercise I practiced today, something I already did on the AWS laboratories during the AWS re/Start programme. With this exercise I learned to send emails using AWS Lambda and Amazon SES (Simple Email Service). Here's a detailed overview of what I did and what I learned.
🔎 Steps to Send an Email Using AWS Lambda and SES:
Set Up SES:
In the AWS Console, search for SES.

Create an Identity for your email address.
.jpg)

Verify your email by checking your inbox.




Create IAM Role:
Go to IAM (Identity and Access Management) in the AWS Console.

Create a role for Lambda with Amazon SES Full Access.




Create Lambda Function:
In the AWS Console, search for Lambda and create a new function.

Name your function and choose Python as the runtime.

Assign the IAM role you created earlier to the Lambda function and hit “Create Function”.

Write the Code:
import json
import boto3
def lambda_handler(event, context):
client = boto3.client("ses")
subject = "Test Subject from Lambda"
body = "Test body from Lambda"
message = {
"Subject": {"Data": subject},
"Body": {"Html": {"Data": body}}
}
response = client.send_email(
Source="[email protected]",
Destination={"ToAddresses": ["[email protected]"]},
Message=message
)
return response
Use the boto3 library to interact with AWS services.
Define the SES client and construct the email subject and body.
Use the send_email method to send the email.

Deploy and Test:
Deploy your Lambda function. You need to always deploy after any changes to the function before testing.
Create and run a test event to see the email in your inbox.

Here you can see that the function worked and there isn’t any error.

Check your email for the email. (Don’t forget to check your spam folder!)

→ What I Learned:
→ AWS Services Used:
This project was a fantastic learning experience, helping me understand the power of serverless architectures and cloud-based email services.