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.
Python
client.send_email(
Source='me@example.com',
Destination={'ToAddresses': ['me@example.com']},
Message={
'Subject': {'Data': 'My Subject'},
'Body': {
'Html': {'Data': '
Hello World
'},'Text': {'Data': 'Hello World'}
}
}
)
Pro Tip: Use inline CSS for email templates, as Gmail and Outlook often strip external stylesheets.

Top comments (0)