Rustmailer
A self-hosted Email Middleware for IMAP, SMTP, Gmail API, Graph API — built for developers
Install / Use
/learn @rustmailer/RustmailerREADME
🎯 Use Cases
RustMailer is designed to be seamlessly integrated into your applications, helping you save development time and improve efficiency by providing a robust, self-hosted email synchronization and delivery backend supporting IMAP/SMTP, and Gmail API.
Typical use cases and industries include:
- SaaS platforms requiring multi-account email synchronization (IMAP or Gmail)
- CRM systems with automated transactional email sending
- Marketing automation tools supporting dynamic email templates
- Customer support software integrating real-time email notifications
- Enterprise applications needing reliable IMAP, SMTP, or Gmail API handling
- E-commerce platforms managing order confirmation and promotional emails
- Data analytics solutions tracking email opens and clicks via webhooks
- Fintech and healthcare systems demanding secure and auditable email workflows
RustMailer enables developers to focus on core application logic without building complex mail infrastructure from scratch.
<img width="1141" height="480" alt="image" src="https://github.com/user-attachments/assets/a143096b-e5d4-4966-af03-82eb53003a64" />💡 Why RustMailer?
While many programming languages provide IMAP, SMTP, or Gmail API client libraries, building a reliable, scalable, and feature-rich mail synchronization and delivery system from scratch remains complex and time-consuming. RustMailer abstracts these challenges by offering a unified, self-hosted middleware service that:
- Handles multi-account IMAP polling and caching efficiently
- Provides robust SMTP sending capabilities with template support
- Manages event dispatch (webhooks, message queues) out of the box
- Simplifies integration across diverse application stacks regardless of language
This allows development teams to focus on core business logic, accelerating time-to-market and reducing maintenance overhead compared to assembling disparate mail client libraries individually.
✨ Features
- 🌐 Modern APIs – Offers both gRPC and OpenAPI interfaces with multi-version API documentation.
- 🚀 High Performance & Cost-Efficient – Written in Rust for safety and speed. Runs with low memory usage, no Redis or external dependencies required — ideal for production at minimal cost.
- 📬 Multi-account IMAP support – Incremental sync using UID-based strategy, supports folder selection, windowed or date-range sync.
- 📤 SMTP Sending – Manage outgoing email via SMTP with connection pooling.
- 📮 Gmail API Support – Native integration with Gmail API for account authentication, incremental synchronization, and message sending. Ideal for modern Google Workspace environments.
- 🧾 Email Template Support – Supports dynamic email templates for transactional and marketing messages.
- 📡 Flexible MTA Integration – Send via account-specific SMTP servers, self-hosted MTA services, or third-party providers.
- 📈 Open & Click Tracking – Built-in support for tracking email opens and link clicks.
- 🔄 Webhooks with VRL – Send webhook payloads to external systems and process them with VRL scripts for filtering and transformation.
- 🔌 NATS Integration – Push real-time events to NATS for seamless integration with downstream systems.
- 🖥️ Web UI & Client – Includes a built-in web-based email client and admin dashboard.
- 🔐 OAuth2 Support – Built-in OAuth2 flow with web-based authorization UI. Automatically manages access and refresh tokens.
- 🌍 Proxy Support – Supports proxies for IMAP, SMTP, and OAuth2 connections in restricted environments.
📸 Snapshot
| <img width="1548" height="861" alt="image" src="https://github.com/user-attachments/assets/46e886e5-8f17-4ab5-872e-072686e52d71" />| <img width="1552" height="741" alt="image" src="https://github.com/user-attachments/assets/054b1e1e-294e-4af0-a09a-3040552d4f90" />| |-------------------------------------|--------------------------------| | <img width="1553" height="860" alt="image" src="https://github.com/user-attachments/assets/ddd7e1a9-34dc-459b-8701-b59016b8c6e7" />| <img width="1551" height="855" alt="image" src="https://github.com/user-attachments/assets/753102d0-7df7-4efb-9099-c5beb6bf0c79" />|
API Reference
https://rustmailer.com/redoc
📦 Installation
🔧 Build from Source
To build RustMailer from source, you need the following prerequisites:
- Rust ≥ 1.88 (recommended: latest stable)
- Node.js ≥ 20
- pnpm (for building Web UI)
Step 1: Clone the repository
git clone https://github.com/rustmailer/rustmailer.git
cd rustmailer
Step 2: Build the Web UI
cd web
pnpm install
pnpm run build
cd ..
Step 3: Build the Rust backend
cargo build --release
✅ You can now run the binary from ./target/release/rustmailer.
./target/release/rustmailer --rustmailer-root-dir /tmp/data
🐳 Prefer Docker?
If you don’t want to build manually, you can follow the Docker-based installation guide here: 📄 Install via Docker
docker run -d --name rustmailer -p 15630:15630 -p 16630:16630 -e RUSTMAILER_ROOT_DIR=/data -v /sourcecode/rustmailer_data/:/data rustmailer/rustmailer:latest
🔐 RustMailer offers a free 14-day trial with unlimited email accounts during the trial period. See License for details. A valid license key is required for continued use after the trial.
⚙️ Configuration
RustMailer can be configured via environment variables or command-line arguments parsed by Clap.
The CLI configuration code is located at src/modules/settings/cli.rs.
For detailed option descriptions, please refer to the configuration reference.
# Root directory for RustMailer data storage
RUSTMAILER_ROOT_DIR=/data/rustmailer_data
# HTTP server listening port
RUSTMAILER_HTTP_PORT=15630
# Enable gRPC server
RUSTMAILER_GRPC_ENABLED=true
# gRPC server listening port
RUSTMAILER_GRPC_PORT=16630
# IP address to bind the server to (0.0.0.0 means all interfaces)
RUSTMAILER_BIND_IP=0.0.0.0
# Public URL of the RustMailer service (used in links and callbacks)
RUSTMAILER_PUBLIC_URL=http://localhost:15630
# Enable logging output to a file
RUSTMAILER_LOG_TO_FILE=true
# Enable access token authentication for API requests
RUSTMAILER_ENABLE_ACCESS_TOKEN=true
🧪 API Access
RustMailer exposes both REST (OpenAPI) and gRPC APIs for programmatic access.
You can browse all available API documentation directly via the Web UI:
🔗 OpenAPI Documentation Entry Point: http://localhost:15630/api-docs
It provides links to:
- Swagger UI:
/api-docs/swagger - ReDoc:
/api-docs/redoc - Scalar API Explorer:
/api-docs/scalar - OpenAPI Explorer:
/api-docs/explorer - OpenAPI Spec (JSON):
/api-docs/spec.json - OpenAPI Spec (YAML):
/api-docs/spec.yaml
🧠 Webhooks & NATS
RustMailer supports periodic detection of mail changes (e.g. new messages, flag updates, etc.) using scheduled scans.
It does not rely on real-time push, but instead performs full or incremental synchronization at configurable intervals.
Mail events are then emitted as:
RustMailer detects mail changes (e.g. new messages, flag updates, etc.) by periodically scanning IMAP folders.
It performs either full or incremental synchronization, depending on configuration. see details https://rustmailer.com/docs/guide/imap-sync
Detected events can be forwarded using:
- Webhooks – Supports payload transformation using VRL
- NATS Messages – Also supports VRL scripting for custom routing and filtering
<img width="1549" height="796" alt="image" src="https://github.com/user-attachments/assets/71477c2f-1ad5-4cd8-884c-6be0867007bd" />🔧 Each mail account can be configured with either a webhook or a NATS sink — not both.
🌐 In addition, RustMailer supports one or more global hooks, which apply to all accounts.
🖥️ Web Interface
RustMailer includes a lightweight web-based mail client and admin panel, primarily designed to help developers debug and inspect synced mail content.
Accessible at:
http://localhost:15630
🔐 Web UI Access Control
- If
RUSTMAILER_ENABLE_ACCESS_TOKEN=false(default), the Web UI is accessible without authentication. - If
RUSTMAILER_ENABLE_ACCESS_TOKEN=true, access is restricted to requests that provide a valid root token.
The root token file is generated at startup under the directory specified by
--rustmailer-root-dir
or theRUSTMAILER_ROOT_DIRenvironment variable.
The token is stored in a file named:root
⚠️ The root access session expires after 5 days and requires re-authentication.
From 1.4.0, By default, the Web UI uses username/
Related Skills
himalaya
342.0kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
coding-agent
342.0kDelegate coding tasks to Codex, Claude Code, or Pi agents via background process
