Maileroo is a programmable self-hosted email forwarding gateway, private alias manager, and SMTP server built in Rust. It allows you to run your own private email forwarding service (similar to SimpleLogin or Firefox Relay) using your own domain names.
Maileroo acts as a secure intermediary between the public internet and your personal inbox (such as Gmail or ProtonMail).
When an email is sent to an alias on your registered domain (e.g., shopping@yourdomain.com):
- Maileroo accepts the connection on Port 25, parses the email, and verifies that the alias exists in the database.
- It rewrites the sender envelope address using the Sender Rewriting Scheme (SRS) (e.g., rewriting sender@gmail.com to SRS0+hash=timestamp=gmail.com=sender@yourdomain.com). This ensures that forwarding the email does not break SPF and DMARC checks.
- It forwards the email to your configured real personal inbox.
If you click reply from your personal inbox:
- Your mail client sends the reply back to the rewritten SRS address at Maileroo.
- Maileroo validates the cryptographic HMAC signature of the SRS address to prevent spam or spoofing.
- It decodes the original sender address, removes your personal address from the headers, and sends the reply to the original sender. Your real personal inbox remains completely hidden.
Maileroo includes an integrated web server that serves a lightweight administrative dashboard:
- Create and manage email domains and secure aliases.
- Manage API keys for programmatic integration.
- Rotate DKIM selectors and keys dynamically with zero downtime.
- Monitor live email delivery queues and retry histories.
- Inbound SMTP Daemon: Handles high-concurrency connections on Port 25 with integrated tarpitting, slowloris read timeouts, and disk-buffered OOM protection.
- Unified Database Layer: Supports both zero-dependency local SQLite databases and multi-node PostgreSQL clusters out of the box, with automated schema migrations on startup.
- Native Auto-TLS: Performs Let's Encrypt HTTP-01 and TLS-ALPN-01 ACME challenge negotiation natively on Port 80 and 443 to secure both web traffic and SMTP STARTTLS dynamically.
- Outbound Relay Fallback: Safely routes outgoing mail through trusted upstream relays (such as Amazon SES, Postmark, or SendGrid) to bypass Port 25 blocks on cloud VPS providers.
- DKIM Signing: Dynamically signs all outgoing mail (firsthand sends and forwarded replies) using secure, modern Ed25519 (Elliptic Curve) signatures.
- Web Framework: Axum and Tower-Sessions.
- Frontend rendering: HTMX and Askama Templates.
- Async Runtime: Tokio.
- Crypto and Network: Tokio-Rustls, Rustls-ACME, and Hickory-Resolver.
Copy the sample environment configuration file:
cp .env.example .envStart the local development database and a Step-CA instance for offline TLS certificate validation:
docker compose -f docker-compose.dev.yml up -dGenerate self-signed STARTTLS certificates for local development:
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -keyout certs/smtp_key.pem -out certs/smtp_cert.pem -sha256 -days 365 -nodes -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"Initialize the database and tables:
cargo run --bin setup_db# Start the Maileroo Monolith
cargo run
# Run the local SMTP testing client in a separate terminal
cargo run --bin smtp-testMaileroo provides a highly optimized, fully self-contained Docker image that packages the application binary, embedded migrations, and compiled static assets.
An easy, zero-dependency SQLite-based setup is provided in the docker/ directory.
-
Navigate to the
docker/directory or run the command using the file flag:docker compose -f docker/docker-compose.yml up -d
-
Make sure to customize the environment variables in
docker/docker-compose.yml:SRS_SECRET: A secure random string for Sender Rewriting Scheme cryptographic signature.PROD_DOMAIN: Your primary mail domain.ADMIN_EMAIL&ADMIN_PASSWORD: Credentials to set up your primary admin account on first start.
All emails, certificates, and SQLite database data will persist under a named Docker volume (maileroo-data).
To compile and build the self-contained production image on your machine:
docker build -t maileroo .src/inbound/: Inbound SMTP server, connection rate-limiting, blocklisting, and protocol session state.src/outbound/: Outbound mail sending, SRS encoding, DKIM signing, and delivery retry queue daemon.src/web/: REST API endpoints, session authentication, HTMX dashboard views, and the native Auto-TLS certificate server.src/db/: Unified database pool dispatcher supporting dynamic SQLite/PostgreSQL execution.