Mock SMTP server that logs the emails it receives
Project description
smtp-logger
Mock SMTP server that logs the emails it receives.
Listens to inbound connections from SMTP clients. Supports a very minimal set of SMTP features, but probably enough that most clients will communicate happily and emails will get "delivered" as expected.
Why?
This is useful in development, typically as part of a docker-compose.yml
.
There have been a couple cases recently where I wanted to work with an OSS tool that required a configured SMTP server (for instance, to send password reset or login link emails). The tool itself didn't offer an alternative, so creating a simple logging SMTP service seemed like the best way to go.
Installation and usage via Docker
This is probably how you want to use smtp-logger
. This way your project does not need to depend on python (even though the docker image does).
The latest version of smtp-logger
is packaged in a docker image available at ghcr.io/literalgarage/smtp-logger:latest
.
For instance, to create an smtp
logger service in your docker-compose.yml
:
smtp:
image: ghcr.io/literalgarage/smtp-logger:latest
environment:
- SMTP_LOGGER_PORT=8025
ports:
- "8025:8025"
Installation and usage locally
Install this library using pip
:
pip install smtp-logger
This provides an smtp-logger
binary:
> smtp-logger --host 0.0.0.0 --port 8025
It accepts only --host
and --port
parameters. These are optional.
If not supplied, the SMTP_LOGGER_HOST
and SMTP_LOGGER_PORT
environment variables are used. These are also optional.
If configuration is missing then, by default, SMTP_LOGGER_HOST
is 0.0.0.0
and SMTP_LOGGER_PORT
is 8025
.
Development
This is the simplest SMTP logging implementation that worked for the specific cases I ran into. There are an enormous number of basic and advanced SMTP features this server doesn't yet support. Its handling of content-transfer-encoding
s is weak at the moment. It doesn't support TLS. etc.
I'd love your help improving this tool!
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd smtp-logger
python -m venv .venv
source .venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[dev]'
To run tests:
make test
To run a full lint/typecheck/test pass:
make check
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file smtp-logger-0.0.1.tar.gz
.
File metadata
- Download URL: smtp-logger-0.0.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2469dcfccf5e5c2156966b209c99295db47f54cf11ea54973e820927896e01e |
|
MD5 | 19ae2657d2275d38d6be8a07a6766e0d |
|
BLAKE2b-256 | dc008ff11a5baab1cc60a865267dafb545b97be0a56f7bcc46bb71b0cdbfd1a8 |
File details
Details for the file smtp_logger-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: smtp_logger-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e03be5a6cde9763cb1398aba7a6d3d33b21a4a8080b8867d36322d36c0877227 |
|
MD5 | 3b322aa0020ba20ad5d836b8d7c36f7f |
|
BLAKE2b-256 | d410fde3b04e7ee0dfcd0afee100154c8f393e49fdabc70ad75a968a5e1097cf |