A Dockerized Python SMTP server that receives emails and forwards them to a RESTful API endpoint.
- SMTP Server: Listens for incoming SMTP connections
- Email Parsing: Extracts email content, headers, and attachments
- Authentication Support: Captures SMTP AUTH credentials (username/password)
- REST API Forwarding: Sends all email data as JSON to a configured API endpoint
- Attachment Handling: Base64-encodes attachments for API transmission
- Client Metadata: Includes client IP and other connection details
- Start the service:
docker-compose up -d- Stop the service:
docker-compose down- Build the Docker image:
docker build -t smtp2api .- Run the container:
docker run -p 8025:8025 -e API_URL=http://your-api-endpoint/api/email smtp2api- Install dependencies:
pip install -r requirements.txt- Create a
.envfile (optional):
cp .env.example .env
# Edit .env with your configuration- Run the server:
python3 app/smtp_service.pyA test script is included to verify the server functionality:
python3 tests/test_send.pyYou can also use the included mock API server for testing:
# In one terminal
python3 tests/mock_api.py
# In another terminal
python3 app/smtp_service.py
# In a third terminal
python3 tests/test_send.py- The server is configured with
auth_require_tls=Falsefor development. In production, enable TLS. - SMTP credentials are forwarded in plain text in the JSON payload. Ensure your API endpoint uses HTTPS.
- Consider implementing IP whitelisting or additional authentication for production use.
MIT