Day 20: Sending HTML Emails from AWS Lambda using Python & SES.

Published: (January 16, 2026 at 11:00 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Cover image for Day 20: Sending HTML Emails from AWS Lambda using Python & SES.

Beyond Plain Text

Welcome to Day 20. SNS is great for SMS or internal alerts, but for user‑facing emails, you need HTML. Enter Amazon SES.

Prerequisites

  • Verify your email in the SES Console (Identities).
  • Add ses:SendEmail permissions to your Lambda IAM Role.

The Code (Python)

Unlike SNS which just takes a string, SES expects a dictionary structure for MIME types.

client.send_email(
    Source='me@example.com',
    Destination={'ToAddresses': ['me@example.com']},
    Message={
        'Subject': {'Data': 'My Subject'},
        'Body': {
            'Html': {'Data': '''
## Hello World
'''},          # HTML part
            'Text': {'Data': 'Hello World'}  # Plain‑text fallback
        }
    }
)

Pro Tip

Use inline CSS for email templates, as Gmail and Outlook often strip external stylesheets.

SES email example

Back to Blog

Related posts

Read more »

Rapg: TUI-based Secret Manager

We've all been there. You join a new project, and the first thing you hear is: > 'Check the pinned message in Slack for the .env file.' Or you have several .env...

Technology is an Enabler, not a Saviour

Why clarity of thinking matters more than the tools you use Technology is often treated as a magic switch—flip it on, and everything improves. New software, pl...