How zone-eu/zonemta-wildduck works
Project type and purpose
• This is a Node.js plugin module (“zonemta-wildduck”) that extends ZoneMTA (an SMTP server) with WildDuck authentication and delivery features.
• Its primary role is to sit inside ZoneMTA as an MSA (Mail Submission Agent) plugin, enforce user‐based sending restrictions, rewrite message headers, upload sent mail to IMAP, and decide whether to hand off locally or via MX.
File structure
• Top-level files:
– index.js: the plugin entry point where it registers hooks with ZoneMTA
– config.example.toml: plugin configuration schema (authentication toggles, mailbox limits, LMTP settings)
– package.json & lock: NPM metadata and dependency lockfile
– Dockerfile, Gruntfile.js, .github/workflows/*: CI/CD and build/test pipelines (unit tests, linting, releases)
• Lint & formatting: .eslintrc, .prettierrc.js, .ncurc.js
• GitHub workflows for testing and Docker image creation indicate it can be deployed as a containerized plugin.
README for insights
• Describes five core features: authentication, From rewriting, “Sent Mail” upload, recipient rate limiting, and local LMTP delivery.
• Shows integration points: SMTP interface of ZoneMTA (port 587), WildDuck user store (via its HTTP or IMAP API), and LMTP for local delivery.
• Configuration driven by TOML options.
a. Main components:
– SMTP Client (e.g., mail user agent)
– ZoneMTA SMTP Interface (port 587)
– zonemta-wildduck Plugin (index.js logic)
– WildDuck Server (authentication API + IMAP storage)
– LMTP Server (for local delivery)
– DNS/MX lookup (for remote delivery)
– Configuration Store (config.example.toml)
b. Relationships & data flows:
1. SMTP Client → ZoneMTA
2. ZoneMTA invokes zonemta-wildduck plugin hooks
3. Plugin → WildDuck authentication API (check credentials)
4. Plugin rewrites From header if needed
5. Plugin → WildDuck IMAP “Sent Mail” append
6. Plugin decides:
• If recipient domain hosted locally → LMTP Server
• Else → DNS MX lookup → remote SMTP delivery
c. Architectural patterns & design principles:
– Plugin architecture (ZoneMTA’s hook system)
– Single responsibility (authentication, rewriting, upload, routing)
– Configuration-driven behavior via TOML
– External service integration (WildDuck, DNS, LMTP)
d. Key technologies & libraries:
– Node.js runtime
– ZoneMTA plugin API
– WildDuck HTTP/IMAP APIs
– LMTP protocol
– NPM packaging, Docker for deployment, GitHub Actions for CI
Diagramming conventions
– Green: internal modules (ZoneMTA, Plugin)
– Blue: external services (WildDuck, DNS, LMTP)
– Gray: configuration/CI tools
Key reminders
• Be exhaustive but not overly granular: capture all core data flows and integration points.