This is a complete example of using OwlMail email testing service. OwlMail is an SMTP server and Web interface for development and testing environments that can capture and display all sent emails. It is fully compatible with MailDev API, providing better performance and richer features.
- ✅ Email Capture: Capture all sent test emails
- ✅ Web Interface: View emails through Web interface exposed via Traefik
- ✅ SMTP Server: Provides SMTP server for applications to connect
- ✅ Email Persistence: Supports email data persistence storage
- ✅ HTTP Basic Auth: Optional configuration to protect Web interface
- ✅ Email Forwarding: Supports forwarding emails to real SMTP server
- ✅ 100% Compatible with MailDev API: Fully compatible with MailDev API
Before using this configuration, you need to configure the following environment variables in owlmail/.env:
# Service configuration
SERVICE_NAME=owlmail
SERVICE_PREFIX=owlmail
SERVICE_DOMAIN=mail.example.com
SERVICE_PORT=1080
DOCKER_IMAGE=ghcr.io/soulteary/owlmail:0.3.0
# SMTP configuration
SMTP_PORT=1025
SMTP_HOST=0.0.0.0
# Data directory
DATA_DIR=./owlmail-data
# Health check and logging configuration
HEALTH_CHECK_INTERVAL=10s
HEALTH_CHECK_TIMEOUT=3s
HEALTH_CHECK_RETRIES=3
LOG_MAX_SIZE=10m
LOG_MAX_FILE=3
# Optional configuration
# MAILDEV_WEB_USER=admin # HTTP Basic Auth username
# MAILDEV_WEB_PASS=password123 # HTTP Basic Auth password
# MAILDEV_VERBOSE=false # Log level (normal, verbose, silent)
# MAILDEV_MAIL_DIRECTORY=/data/mails # Email storage directory (configured via volumes)- Docker 20.10+
- Docker Compose 2.0+
- Traefik service started (refer to
../../traefik/) - Traefik Docker network created
Configure domain in owlmail/.env:
SERVICE_DOMAIN=mail.example.comEnsure domain DNS resolution is correct (mail.example.com)
docker compose -f traefik-app-examples/owlmail/docker-compose.yml up -d-
Web Interface:
- Access
https://mail.example.comto view all captured emails
- Access
-
SMTP Server:
- SMTP server address:
localhost:1025 - For applications to connect and send test emails
- SMTP server address:
This configuration includes the following main features:
-
Port Configuration:
- SMTP port (1025): Directly exposed for applications to connect
- Web port (1080): Exposed via Traefik, supports HTTPS
-
Email Storage:
- Email data is persistently stored in
./owlmail-datadirectory - Mounted to container via volumes
- Email data is persistently stored in
-
Traefik Integration:
- Web interface exposed via Traefik
- Supports HTTPS and automatic redirect
Configure the following environment variables in your application:
# Environment variable example
SMTP_HOST=localhost
SMTP_PORT=1025
SMTP_USER= # Optional, if SMTP authentication is enabled
SMTP_PASS= # Optional, if SMTP authentication is enabledEmail data is saved in ./owlmail-data directory and will not be lost even if the container restarts.
If you need to protect the Web interface, uncomment environment variables:
MAILDEV_WEB_USER=admin
MAILDEV_WEB_PASS=password123You can configure email forwarding to real SMTP server:
# Forwarding configuration example
MAILDEV_OUTGOING_HOST=smtp.example.com
MAILDEV_OUTGOING_PORT=587
MAILDEV_OUTGOING_USER=your-email@example.com
MAILDEV_OUTGOING_PASS=your-password
MAILDEV_OUTGOING_SECURE=trueUse command-line tools to send test emails:
# Using telnet
telnet localhost 1025
# Send email
HELO localhost
MAIL FROM: test@example.com
RCPT TO: recipient@example.com
DATA
Subject: Test Email
This is a test email.
.
QUITConfigure SMTP settings in your application:
# Python example
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('Test email body')
msg['Subject'] = 'Test Email'
msg['From'] = 'sender@example.com'
msg['To'] = 'recipient@example.com'
smtp = smtplib.SMTP('localhost', 1025)
smtp.send_message(msg)
smtp.quit()Access Web interface https://mail.example.com to view all captured emails.
-
Check if port is exposed:
docker ps | grep owlmail -
Check firewall:
- Confirm firewall allows port 1025
- Confirm port is not occupied by other services
-
Check service logs:
docker logs owlmail
-
Check Traefik configuration:
- Confirm service is in
traefiknetwork - Confirm domain DNS resolution is correct
- Confirm service is in
-
Check Traefik logs:
docker logs traefik
Email data is stored in ./owlmail-data directory. If data is lost:
- Check if directory exists
- Check directory permissions
- Check if volumes configuration is correct
Delete data directory and restart service:
rm -rf ./owlmail-data
docker compose -f traefik-app-examples/owlmail/docker-compose.yml restart owlmailConfigure forwarding-related environment variables in .env file:
MAILDEV_OUTGOING_HOST=smtp.example.com
MAILDEV_OUTGOING_PORT=587
MAILDEV_OUTGOING_USER=your-email@example.com
MAILDEV_OUTGOING_PASS=your-password
MAILDEV_OUTGOING_SECURE=trueThen restart the service.