MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. Great for development and testing!
This code packages MailCatcher as a container image. This image is only ~75 MB. It is based on Dietrich Rordorf's Dockerfile, and customized to:
- Modify the start command
- Run as a non-root user
- Pin software versions to create immutable images
To use this, run the container with podman
(or replace podman
with docker
if preferred):
podman run -d --rm -p 2525:2525 -p 8080:8080 --name mailcatcher ghcr.io/clifford2/mailcatcher:0.10.0-8
Configure your application to deliver mail to SMTP port 2525.
You can send a test email with our hello
test script (uses netcat):
podman exec -it mailcatcher hello
Additional tools for testing email sending include:
socat - TCP4:0.0.0.0:2525
netcat 0.0.0.0 2525
telnet 0.0.0.0 2525
Example commands for socat / netcat:
MSG="HELO mailcatcher.example.com\nMAIL FROM: mailcatcher@example.com\nRCPT TO: clifford@example.org\nDATA\nSubject: CLI Test Message\nContent-Type: text/plain\n\nHello Buddy\n\nWhat's up?\n\nRegards,\nMailCatcher\n.\nquit\n"
echo -e "$MSG" | socat - TCP4:0.0.0.0:2525
podman exec mailcatcher sh -c "echo -e \"$MSG\" | nc 0.0.0.0 2525
View the caught emails in the web interface at http://localhost:8080/.
- MailCatcher source code: https://github.com/sj26/mailcatcher
- Container image available at:
- Docker build based on https://github.com/rordi/docker-mailcatcher
.msmtprc
: Sample config file for msmtpssmtp.conf
: Sample config file forssmtp
This code is shared under the MIT License.
The original Dockerfile is © 2016 Dietrich Rordorf dr@ediqo.com.
Modifications, and all other files are © Clifford Weinmann https://www.cliffordweinmann.com/.
This code is provided AS IS, without warranty of any kind.
See LICENSES/MIT.txt
for the full license text and disclaimer.
This code is updated as often as possible, but support is provided on a best effort basis only.
Please report any problems or vulnerabilities by opening a GitHub issue here.