FastSMTP¶
A TLS-capable, async SMTP server that receives emails and forwards them to webhooks. Built with Python 3.12+ for integration with n8n and other webhook-based workflow platforms.
Features¶
- SMTP Server: Dual-port support (plain SMTP and TLS), STARTTLS with optional enforcement, hot-reload TLS certificates
- Email Authentication: DKIM and SPF verification with configurable enforcement
- Webhook Delivery: Reliable delivery queue with exponential backoff retry, dead letter queue (DLQ) notifications
- S3 Attachment Storage: Optional S3-compatible storage (AWS S3, MinIO, Ceph) with presigned URL support
- Raw Message Preservation: Optional complete-MIME archiving to S3, configurable per domain and per rule
- Rule Engine: Conditional routing based on email attributes (from, to, subject, headers, etc.)
- REST API: Full management API with OpenAPI documentation
- Multi-tenant: Domain-based isolation with role-based access control
- Rate Limiting: Configurable limits for both API and SMTP (per-IP connection/message limits)
- Prometheus Metrics:
/metricsendpoint with SMTP, webhook, queue and auth metrics, with optional IP allowlisting - Security: SSRF protection for webhook URLs, salted API key hashing, scoped API keys, optional encryption at rest for webhook headers and delivery-log payloads
- Queue Backpressure: Configurable limits to prevent unbounded queue growth
- Soft Delete: Deleted users, API keys, domains and recipients are restorable; delivery history survives, permanent removal is a separate superuser step or an optional retention job
- Automatic Cleanup: Background worker for delivery-log and soft-delete retention
- Horizontal Scaling: Stateless design with database-backed task distribution
Architecture¶
flowchart LR
client[Email Client] --> smtp[SMTP Server<br>ports 2525, 4650 TLS]
smtp --> db[(Database<br>PostgreSQL)]
api_clients[API Clients<br>CLI, Web] --> api[REST API<br>port 8000]
api <--> db
db --> worker[Webhook Worker<br>background]
worker --> hooks[Webhook Endpoints]
Email Flow¶
- Client connects to SMTP server
- Server validates recipient against configured domains
- Email is received and parsed (headers, body, attachments)
- DKIM and SPF verification runs in parallel
- Rules are evaluated to determine routing
- Email is queued for webhook delivery
- Worker delivers to webhook with retry logic
Next Steps¶
- Getting Started - install and run FastSMTP locally or with Docker
- Configuration - all environment variables
- Webhook Payload - what your webhook receives
- Monitoring - Prometheus metrics, health checks, and restricting scrape access
- CLI Reference - server and remote CLI tools
License¶
AGPL-3.0-or-later - this program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the LICENSE file for details.