Skip to content

How to trigger SMTP server errors using the JIM extension for MailHog

License

Notifications You must be signed in to change notification settings

garis-space/mailhog-jim-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to trigger SMTP server errors using the JIM extension for MailHog.

I'll show you how to run a MailHog local SMTP server in a Docker container with the JIM extension which will trigger errors when sending emails from a simple Python script.

MailHog with JIM

Prerequisites

Optional Step 1 - Create a virtual environment

If you want to use a virtual environment, you can create one with the following commands:

# Download latest Miniconda https://docs.conda.io/en/latest/miniconda.html for your OS

# Create a virtual environment
conda create -n mailhog-jim-python python=3.10
conda activate mailhog-jim-python

Step 2 - Clone the repository and start Docker Compose

# Clone the repository
git clone https://github.com/garis-space/mailhog-jim-python.git
cd mailhog-jim-python

# Environment variables (edit as needed)
cp .env.example .env

MailHog use Jim chaos monkey extension to fail sending emails. You can configure the probability of failure in the .env file. Default value is 0.2 and it means that 20% of emails will be rejected.

# Start Docker Compose
docker compose up

Step 3 - Run the Python script

# Run the Python script
python main.py

Step 4 - Check the email in MailHog

Open your browser and go to http://localhost:8025 to see the email sent by the Python script.

Step 5 - Stop Docker Compose

docker compose down

Step 6 - Optional Delete the virtual environment

conda deactivate
conda remove -n mailhog-jim-python --all

About

How to trigger SMTP server errors using the JIM extension for MailHog

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages