Overview
Discover what makes Mail-in-a-Box powerful
Mail‑in‑a‑Box is a turnkey, self‑hosted mail appliance that turns a clean Ubuntu 22.04 LTS VM into a fully functional, secure email stack with a single script run. From a developer’s point of view it is an opinionated, idempotent configuration‑management system that bundles the core services required for a modern mail provider—SMTP, IMAP, webmail, calendar/contacts, DNS, TLS, and monitoring—into a coherent, auditable deployment.
Operating System
Mail Transport
Mail Retrieval
Web & Calendar
Overview
Mail‑in‑a‑Box is a turnkey, self‑hosted mail appliance that turns a clean Ubuntu 22.04 LTS VM into a fully functional, secure email stack with a single script run. From a developer’s point of view it is an opinionated, idempotent configuration‑management system that bundles the core services required for a modern mail provider—SMTP, IMAP, webmail, calendar/contacts, DNS, TLS, and monitoring—into a coherent, auditable deployment.
Technical Stack & Architecture
- Operating System – Ubuntu 22.04 LTS (Debian‑based, 64‑bit).
- Mail Transport –
postfix(MTA) configured withpostgreyfor greylisting andOpenDKIMfor DKIM signing. - Mail Retrieval –
dovecot(IMAP/POP3) with integrated spam filtering viaspamassassin. - Web & Calendar –
Nextcloudfor CalDAV/CardDAV,Roundcubeas the webmail UI, andz-pushfor Exchange ActiveSync. - Web Server –
nginxhosts webmail, static content, and the auto‑configuration endpoint. - DNS –
nsd4runs as an authoritative server, automatically generating SPF, DKIM, DMARC, DNSSEC, DANE TLSA, and MTA‑STS records. - TLS – Let’s Encrypt integration via
certbot(or an internal wrapper) provisions certificates for all services. - Monitoring & Security –
ufwfirewall,fail2ban, basic system monitoring (munin), and daily health checks. - Backup –
duplicitysnapshots to remote storage, managed via the control panel.
The entire stack is orchestrated by a Bash‑based bootstrap script that performs package installation, configuration templating, and service orchestration. The result is an idempotent deployment: re‑running the script on an existing box will re‑apply configuration without side effects.
Core Capabilities & APIs
- Control Panel – A web‑based UI that abstracts user, alias, and DNS management.
- REST API – Exposes all control‑panel actions (user CRUD, alias management, DNS record manipulation, backup configuration) for programmatic automation.
- Webhook Support – The API can trigger HTTP callbacks on events such as new user creation or DNS record changes.
- Extensible DNS Records – The API allows arbitrary TXT/CAA/AAAA records, enabling integration with external services (e.g., Cloudflare).
- Mail Flow Hooks –
dovecotandpostfixcan be extended via custom scripts (postinst,preexec) to inject business logic (e.g., content filtering, analytics).
Deployment & Infrastructure
- Self‑Hosting – Requires a dedicated VM or bare‑metal server with a public IP, 2 GB RAM minimum (4 GB recommended), and at least 20 GB of SSD storage.
- Scalability – While designed for single‑tenant use, the architecture can be scaled horizontally by adding more mail servers behind a load balancer and synchronizing DNS via
nsdzones. - Containerization – No official Docker image, but the component stack can be containerised manually; each service (postfix, dovecot, nginx, nextcloud) can run in its own container with a shared volume for mail data.
- Infrastructure as Code – The bootstrap script can be idempotently applied via Ansible, Terraform (cloud‑init), or cloud‑native CI/CD pipelines.
Integration & Extensibility
- Plugin System – Nextcloud’s plugin ecosystem extends contacts/calendar; Roundcube plugins add custom filters or UI tweaks.
- Custom DNS Zones – The API allows adding custom zones, making it straightforward to host additional domains or subdomains.
- Webhooks & Scripts – Developers can hook into mail events (e.g., deliver‑to, bounce) by configuring Postfix
header_checksor Dovecot ACLs to trigger external services. - API Rate Limits & Authentication – OAuth2 or API keys can be enforced by wrapping the REST endpoint with a lightweight auth layer.
Developer Experience
- Documentation – The README, website, and GitHub wiki provide step‑by‑step guides; the API is documented inline with examples.
- Community & Support – Active GitHub contributors, a Slack channel, and a public forum foster rapid issue resolution.
- Configuration Simplicity – No manual editing of
/etc/postfix/main.cfordovecot.conf; all settings are templated and version‑controlled. - Auditability – Configuration files are stored under
/etc/mailinabox/, making it easy to diff changes or roll back.
Use Cases
- Small‑Business Mail Server – Deploy a single box to host internal and external email for up to ~200 users with minimal overhead.
- Privacy‑Focused Service – Provide end‑to‑end encrypted email for a niche community, leveraging the built‑in TLS and DNSSEC stack.
- Developer Sandbox – Spin up a temporary mail environment for testing webhooks, email templates, or SMTP integrations.
- Educational Platform – Use as a teaching tool for students learning about mail infrastructure, DNS, and security best practices.
Advantages Over Alternatives
| Criterion | Mail
Open SourceReady to get started?
Join the community and start self-hosting Mail-in-a-Box today
Related Apps in apis-services
Mastodon
Decentralized, real‑time social networking
Discourse
Open‑source community forum platform with real‑time chat and AI
Rocket.Chat
Secure, open‑source team communication platform
Novu
Unified notification platform for multi‑channel delivery
Mattermost
Secure, self‑hosted team collaboration with chat, voice, and AI
Jitsi Meet
Free, encrypted video conferencing for everyone
Weekly Views
Repository Health
Information
Explore More Apps
Uguu
Fast, lightweight temporary file hosting
linkding
Self‑hosted bookmark manager for minimal, fast organization
Webtor
Instant torrent streaming and direct downloads in one app
Habitica
Gamify your habits and tasks
Publify
Self‑hosted Ruby on Rails blogging and micro‑publishing platform
Shlink
Self-hosted URL shortener with analytics and QR codes