Reference
Project structure
How the repository is laid out, and which files hold secrets.
Repository
Node mail server
server/src
| Folder | Contents |
|---|---|
main.ts, start.ts | main.ts starts the servers. start.ts generates DNS records. |
config/ | env.ts (the only file that reads environment variables), constants.ts (fixed values and the default settings), mailConfig.ts and smtpMessages.ts (the JSON files), and jsonConfig.ts (loading, validating and reloading them). |
interfaces/ | TypeScript types for DNS records, mail data and PGP keys. |
lib/ | Helpers (email address parsing, raw message handling, the TTL cache, HTTP authentication), logging, SMTP type extensions and workers/, the worker thread pool and its tasks. |
server/ | IncomingServer.ts (port 25), OutgoingServer.ts (port 587), BounceServer.ts (bounce SMTP), BounceWebhookServer.ts (bounce HTTP) and ApiServer.ts (JSON send API). index.ts starts them all and shuts them down. |
server/config/ | DNS checking and generation, mail composing (MailComposer.ts), authentication (MailAuth.ts), spam filtering and PGP in encryption/. |
server/mta/ | Mail delivery: node-mta.ts, the outbound queue (OutboundQueue.ts) and the drivers in drivers/. |
server/plugins/ | Filters, image proxy, rate limiter and tracking protection. |
services/ | IncomingMailHandler.ts, IncomingPolicy.ts, OutgoingMailHandler.ts, OutgoingPipeline.ts, JsonMailHandler.ts, BounceMailHandler.ts, BounceWebhookHandler.ts, IcsEvents.ts and MeetingService.ts. |
services/bounce/ | DsnProcessor.ts, BounceProcessor.ts, BounceRegistry.ts, SuppressionList.ts and DsnBuilder.ts. |
Files that hold secrets
These are in .gitignore. Commit only the .example versions.
| File | Contains |
|---|---|
server/.env | Hostnames, TLS paths, DKIM and PGP keys, relay, Go MTA and KumoMTA passwords, and the API and bounce tokens. |
outbound/.env | KumoMTA settings, DKIM service key, webhook secret. |
outbound/policy/users.lua | SMTP usernames and passwords. Start from users.example.lua. |
relay/.env | Relay settings and the DKIM service key. |
relay/policy/users.lua | Relay accounts: passwords, domains and webhook secrets. Start from users.example.lua. |
server/records.json | Generated DNS records, including the DKIM private key. |
server/spool/ | Queued mail, bounce tracking records and the suppression list. |
*.key, *.pem, outbound/dkim/, relay/dkim/, relay/tls/ | Private keys and certificates. |
Scripts
| Script | What it does |
|---|---|
scripts/run.sh | Runs setup.js. |
scripts/setup.js | Asks for your domain and IP, writes server/.env and generates DNS records. |
scripts/send-mail.js | Sends one DKIM-signed test message straight to a recipient's MX server. |