Self-Hosting SnappyMail with Docker Compose

What Is SnappyMail?

SnappyMail is a fork of RainLoop that rewrites the frontend from scratch, cutting the JavaScript payload from 8 MB to ~138 KB (Brotli-compressed). It connects to any IMAP/SMTP server and gives your users a responsive webmail interface — no database required. If you already run Mailu, Mailcow, or any IMAP server and want a lightweight web frontend, SnappyMail is one of the simplest options to deploy. Official site

Prerequisites

  • A Linux server (Ubuntu 22.04+ recommended)
  • Docker and Docker Compose installed (guide)
  • An existing IMAP/SMTP mail server to connect to
  • 512 MB of free RAM (SnappyMail itself uses ~50 MB)
  • A domain name (optional, for remote access)

Docker Compose Configuration

Create a docker-compose.yml:

services:
  snappymail:
    image: djmaze/snappymail:v2.38.2
    container_name: snappymail
    restart: unless-stopped
    ports:
      - "8888:8888"
    environment:
      UPLOAD_MAX_SIZE: "25M"       # Max attachment size
      MEMORY_LIMIT: "128M"        # PHP memory limit
      SECURE_COOKIES: "true"      # HTTP-only + Secure cookie flags
    volumes:
      - snappymail_data:/var/lib/snappymail
    networks:
      - snappymail

volumes:
  snappymail_data:

networks:
  snappymail:

Start the stack:

docker compose up -d

That’s it — no database container needed. SnappyMail stores all configuration and user data as files in the /var/lib/snappymail volume.

Initial Setup

  1. Open http://your-server:8888/?admin in your browser
  2. Log in with the default admin password: 12345
  3. Change the admin password immediately under Security → Admin password
  4. Go to DomainsAdd Domain
  5. Enter your mail domain (e.g., example.com)
  6. Configure the IMAP server: hostname, port (993 for SSL), encryption (SSL/TLS)
  7. Configure the SMTP server: hostname, port (465 for SSL or 587 for STARTTLS), encryption
  8. Click Test to verify the connection
  9. Open http://your-server:8888/ and log in with your email credentials

Configuration

Upload Size

The UPLOAD_MAX_SIZE variable controls both the PHP upload_max_filesize and Nginx client_max_body_size settings. Set it to match your mail server’s message size limit:

environment:
  UPLOAD_MAX_SIZE: "50M"   # For large attachments

Adding Multiple Mail Domains

SnappyMail supports connecting to multiple mail servers from one instance. In the admin panel under Domains, add each domain with its own IMAP and SMTP settings. Users log in with their full email address and SnappyMail routes to the correct server.

Multi-Account Access

Users can add additional email accounts under Settings → Accounts. Each account connects to its own IMAP/SMTP server. This is built-in — no plugin needed (unlike Roundcube where it requires a plugin).

SettingWhereDefault
Admin passwordAdmin panel → Security12345 (change immediately)
Attachment limitUPLOAD_MAX_SIZE env var25 MB
PHP memoryMEMORY_LIMIT env var128 MB
Cookie securitySECURE_COOKIES env vartrue
Dark modeUser Settings → GeneralDisabled

PGP Encryption

SnappyMail includes built-in PGP support with three options:

  • OpenPGP.js v5 — browser-based encryption, no server-side key storage
  • GnuPG — server-side PGP via the PHP gnupg extension
  • Mailvelope — browser extension integration for key management

Enable PGP in the admin panel under Security → OpenPGP. Users manage their keys under Settings → Security. No plugins required — this ships out of the box.

Sieve Mail Filters

SnappyMail includes a built-in Sieve filter editor. If your IMAP server supports ManageSieve (port 4190), SnappyMail auto-detects it and shows a Filters section in user settings. Users can create rules to sort, forward, or auto-reply to mail without leaving the web interface.

Configure the Sieve server in the admin panel under Domains → [your domain] → Sieve.

Reverse Proxy

Behind Nginx Proxy Manager or Caddy, proxy to port 8888. Example Caddy config:

mail.example.com {
    reverse_proxy snappymail:8888
}

When behind a reverse proxy with SSL, SECURE_COOKIES=true ensures session cookies have the Secure flag set. See our Reverse Proxy Guide for full setup instructions.

Backup

Back up the single data volume:

docker run --rm -v snappymail_data:/data -v $(pwd):/backup \
  alpine tar czf /backup/snappymail-backup-$(date +%Y%m%d).tar.gz -C /data .

This captures all configuration, domain settings, user preferences, and address books. See Backup Strategy for automated approaches.

Troubleshooting

Admin Panel Shows “Unauthorized”

Symptom: Navigating to /?admin returns a 403 or blank page.

Fix: The admin panel is disabled by default in some configurations. Check that /var/lib/snappymail/data/_data_/_default_/configs/application.ini has allow_admin_panel = On. If the file doesn’t exist yet, restart the container — it generates on first run.

IMAP Connection Fails

Symptom: “Authentication failed” when logging in with valid credentials.

Fix: Verify the IMAP hostname and port in the admin panel. Common mistake: using port 143 (STARTTLS) with SSL/TLS encryption mode, or port 993 (SSL) with STARTTLS mode. Match the port to the encryption type your mail server expects.

Attachments Fail to Upload

Symptom: Large attachments fail silently or show an error.

Fix: Increase the UPLOAD_MAX_SIZE environment variable. The default 25M applies to both PHP and Nginx. If behind a reverse proxy, also increase the proxy’s client_max_body_size (Nginx) or equivalent setting.

Session Expires Too Quickly

Symptom: Users get logged out after a few minutes.

Fix: In the admin panel, go to Security → Session timeout and increase the value. Default is 10 minutes of inactivity. For a more forgiving setup, 30–60 minutes works for most users.

Resource Requirements

ResourceIdleUnder Load
RAM~50 MB~100–200 MB
CPUNegligibleLow (PHP-FPM)
Disk~50 MB (application)Grows with user data

SnappyMail is one of the lightest webmail clients available. It uses roughly 3–5x less RAM than Roundcube, and the Docker image is ~30 MB compressed.

Verdict

SnappyMail is the best choice if you want a fast, lightweight webmail client that doesn’t need a database. The built-in PGP support, Sieve filter editor, and multi-account management eliminate the need for plugins that Roundcube requires. The main trade-off: SnappyMail’s plugin ecosystem is smaller and its community is newer. If you need enterprise features like extensive LDAP integration or dozens of community plugins, Roundcube is still the safer choice. For everyone else — especially homelab users and small teams — SnappyMail delivers a better experience with less overhead.

Comments