Skip to content

AWS SES simulator for e2e testing e.g. in pipelines ⚙️

License

Notifications You must be signed in to change notification settings

askrella/aws-ses-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS SES Mock

License: MIT Docker Docker AMD64 Docker ARM64 Build

Askrella

We created this project as a new version of aws-ses-local, which doesn't seem to be maintained for a few years. Our goal is to provide more features, small containers and be more accurate than the alternatives.

⚙️ Getting Started

Running the Docker Container

docker run -p 8081:8081 ghcr.io/askrella/aws-ses-mock:1.0.30

Usage with NodeJS

Using the AWS SDK you can set the endpoint for SES manually by specifying the endpoint in your configuration:

import AWS from 'aws-sdk'
const ses = new AWS.SES({ region: 'us-east-1', endpoint: 'http://localhost:8080' })

Usage with Golang

Using the AWS SDK you can set the endpoint for SES manually by overriding the endpoint resolver:

customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
    if overrideEndpoint, exists := os.LookupEnv("OVERRIDE_SES_ENDPOINT"); exists {
        return aws.Endpoint{
            PartitionID:   "aws",
            URL:           overrideEndpoint,
            SigningRegion: "eu-central-1",
        }, nil
    }

    return aws.Endpoint{}, &aws.EndpointNotFoundError{}
})

cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("eu-central-1"), config.WithEndpointResolverWithOptions(customResolver))

Manual testing

The POST endpoint is available under http://localhost:8080/ and should contain the raw JSON body used for SES messages:

{
    "Action": "SendEmail",
    "Destination": {
        "ToAddresses": [
            "recipient@example.com"
        ],
        "CcAddresses": [
            "cc@example.com"
        ],
        "BccAddresses": [
            "bcc@example.com"
        ]
    },
    "Message": {
        "Body": {
            "Text": {
                "Data": "This is the message body in plain text format."
            },
            "Html": {
                "Data": "<html><body><h1>Hello World!</h1><p>This is the message body in HTML format.</p></body></html>"
            }
        },
        "Subject": {
            "Data": "Test email"
        }
    },
    "Source": "sender@example.com",
    "ReplyToAddresses": [
        "reply-to@example.com"
    ]
}

🧪 Running Tests

To run tests, run the following command

  go test ./internal/*

👋 Contributors

Feel free to open a new pull request with changes or create an issue here on GitHub! :)

⚠️ License

Distributed under the MIT License. See LICENSE.txt for more information.

🤝 Contact Us

In case you need professional support, feel free to contact us