2026-01-08:

Mail catcher

Sometimes you develop. Sometimes you need to send mail. More sometimes (less sometimes?), you need to send mail while you are developing.

Absolutely never should that mail be sent out to the internet. Who would like to receive 50 test emails? All broken.

The safest and simplest way (post your solutions in the comments!) β€” a mail catcher.

A somewhat fake SMTP server that catches mail, and that’s all.

If you do not like to like yourself, you can use the famous one-liner:

$ python -m smtpd -n -c DebuggingServer localhost:1025

Welp, it works. Thanks!

If you want to have a shared mail catcher for a group of people, there is nothing better than mailtrap.io (there is also mailpit, but you have to self-host it).

But if you want to have it on localhost, then just add this to your docker-compose.yml:

# https://mailpit.axllent.org
smtp-mailpit:
    image: axllent/mailpit
    container_name: smtp-mailpit
    ports:
        #- "1025:1025" # pass through STMP port to host machine
        - "8025:8025" # WEB UI port
    environment:
        MP_SMTP_AUTH_ACCEPT_ANY: 1
        MP_SMTP_AUTH_ALLOW_INSECURE: 1

Than somehow find that your new container in your docker somewhere and use it as SMTP server host:1025 with any credentials, and working TLS.

Add a virtual host if your service check domains validity for some reason.

You already know how to do all of this yourself; I do not want to explain obvious basics to you (I do not know how to).

Then send an email, open that your container UI somehow, and enjoy your local mailtrap mailpit!

Very useful, I like it a lot, highly recommend!

#docker #mailtpit #mailtrap #cool