Skip to content

localstack-samples/local-testing-ses-emails-mailhog

Repository files navigation

Local Testing of SES Workflows with LocalStack & MailHog

Key Value
Environment LocalStack
Services SES, SSM, Lambda
Integrations MailHog Extension
Categories Serverless; Email Workflow Testing

Introduction

This project demonstrates how to locally test an SES-based email feedback workflow using LocalStack and the MailHog extension. It includes:

  • A Lambda function that sends feedback emails using SES.
  • SSM Parameter Store for securely storing sender and recipient email addresses.
  • MailHog to intercept and review emails sent via SES for testing.

The workflow includes end-to-end local testing without requiring real AWS credentials.

Prerequisites

Installation

Run the following command to set up the environment and deploy resources:

make install

Configure the MailHog Extension

MailHog is an open-source email testing tool that works with LocalStack to emulate SES email delivery and provides a web UI to inspect sent emails.

To install the MailHog extension, run the following command:

localstack extensions install localstack-extension-mailhog

Make sure that the LocalStack Auth Token is set in the environment.

Start LocalStack

Start LocalStack with the MailHog extension enabled:

make start

Make sure that the LocalStack Auth Token is set in the environment.

Deploy the backend resources

Deploy the Lambda function and SSM parameters:

make deploy-backend

Deploy the frontend resources

Deploy the Preact app to collect feedback:

make deploy-frontend

Access the feedback form on the output URL. Access the MailHog UI at https://mailhog.localhost.localstack.cloud:4566/ to view the emails sent by the Lambda function.

License

This code is available under the Apache 2.0 license.