Skip to main content

WildDuck Server

WildDuck Server

WildDuck is the core component of the Zone Mail Suite. It provides IMAP and POP3 access to email, a comprehensive HTTP API for management, and handles all email storage in MongoDB.

Services

WildDuck runs the following services (each can be independently enabled/disabled):

ServiceDefault PortProtocolPurpose
IMAP993 (TLS)IMAP4rev1Email client access
POP3995 (TLS)POP3Email client access
HTTP API8080REST/JSONManagement, webmail backend

All services support TLS with SNI (Server Name Indication) for hosting multiple domains with different certificates.

Stateless Design

WildDuck instances are completely stateless — all session state is stored in MongoDB and Redis. This means:

  • Multiple WildDuck instances can run simultaneously
  • Users can connect to any instance (no sticky sessions needed)
  • Instances can be added or removed without disruption
  • A TCP load balancer (e.g., HAProxy) distributes connections

Session state is managed as follows:

  • When a mailbox is opened, the current UID list is loaded from MongoDB
  • Changes (new/deleted messages, flag updates) are tracked in a journal collection
  • Redis pub/sub propagates change notifications between instances
  • Each instance applies journal entries to keep its view of the mailbox current

MongoDB Storage Model

WildDuck uses MongoDB as its sole persistent storage backend. Key collections:

Core Collections

  • users — User accounts, passwords, quotas, settings
  • addresses — Email addresses mapped to users (including wildcards)
  • mailboxes — Mailbox hierarchy per user (up to 1500 mailboxes, 128 levels deep)
  • messages — Message metadata, parsed MIME tree, headers, flags
  • threads — Message threading information
  • journal — Write-ahead log for IMAP state changes

Security Collections

  • authlog — Authentication attempt log (TTL-indexed, 30 days)
  • asps — Application-specific passwords
  • audits — Audit records

System Collections

  • settings — System-wide configuration values
  • tasks — Background task queue
  • dkim — DKIM signing keys
  • certs — TLS certificates
  • webhooks — Webhook subscriptions
  • domainaliases — Domain alias mappings
  • domainaccess — Domain allowlists/blocklists

Attachment Storage (separate database)

  • attachments.files / attachments.chunks — Deduplicated message attachments (GridFS)
  • storage.files / storage.chunks — Draft file uploads (GridFS)
  • audit.files / audit.chunks — Audit message copies (GridFS)

Background Tasks

WildDuck includes a task queue system backed by MongoDB and Redis distributed locking. Task types include:

  • user-delete — Asynchronous user account deletion with full data cleanup
  • quota — Quota recalculation
  • acme / acme-update — ACME certificate provisioning and renewal
  • clear-folder — Bulk folder clearing
  • search-apply — Apply filters to existing messages
  • user-indexing — ElasticSearch indexing for a user
  • restore — User data restoration
  • run-migrations — Database schema migrations

ElasticSearch Integration

WildDuck optionally supports ElasticSearch for full-text message search. When enabled:

  • New messages are indexed in real-time via MongoDB change streams
  • Historical messages can be bulk-indexed
  • Search queries use ElasticSearch instead of MongoDB text indexes
  • The feature is gated per-user via a Redis set (feature:indexing)

Key Limits

LimitDefault Value
Max message size64 MB
Max attachment size25 MB
Max mailboxes per user1500
Max mailbox nesting depth128 levels
Default storage quota1 GB per user
Max recipients per message400
Max recipients per day2000
Max forwards per day2000
Max concurrent IMAP connections15 per user
IMAP socket timeout5 min 37 sec

These limits are configurable through the configuration files or the Settings API.