Skip to content

Configuration

mail uses environment variables for process-level configuration and PostgreSQL for values saved through setup or Settings. Feature-specific setting and environment names live with the feature they control instead of in one global variable catalog.

Configuration files

  • .env.example is the web-process template and includes optional feature fallbacks.
  • .env.example.worker is a smaller template for a separately managed worker.
  • A shared .env can be supplied to both processes, as in the repository's Docker Compose file.

Do not commit populated environment files. Give web and worker only the values each process needs.

Precedence

Non-empty values saved through setup or Settings take precedence over scalar authentication, AI, IMAP, and SMTP environment variables. Environment variables remain fallbacks. Additional IMAP and SMTP arrays saved in PostgreSQL and supplied through the environment are both loaded.

DATABASE_URL, ORIGIN, BETTER_AUTH_SECRET, and MAIL_SECRET_KEY are environment-only. The settings cache refreshes within about five seconds after a change. Boolean mail fallbacks use the string false to disable a value; other non-empty values enable it.

Core process settings

VariableProcessDefaultRequirement
DATABASE_URLweb, workernonePostgreSQL connection URL. Required outside demo mode. Both processes must use the same database.
ORIGINweb, workernoneExact public HTTP or HTTPS origin, including a non-standard port. Required for authentication and used by tracking and callback URLs.
BETTER_AUTH_SECRETwebnoneRequired outside demo mode. Use an independent high-entropy value of at least 32 characters in production.
MAIL_SECRET_KEYweb, workeremptyEncrypts stored credentials and private keys. Keep it stable, identical across processes, and backed up.
DEMO_MODEweb, workerfalseAccepts 1, true, yes, or on; see Demo mode.

Generate independent secrets with openssl rand -base64 32. Losing or changing MAIL_SECRET_KEY makes values already encrypted with it unreadable.

Runtime tuning

VariableProcessDefaultDescription
PG_POOL_MAXweb, worker10Maximum PostgreSQL connections per process. The worker example uses 5.
PG_TLS_REJECT_UNAUTHORIZEDweb, workertrueSet to false only for a trusted PostgreSQL server with a private or self-signed certificate. It does not affect HTTPS, IMAP, or SMTP.
HOSTweb0.0.0.0Production Node server listen address.
PORTweb3000Production Node server listen port.
BODY_SIZE_LIMITwebInfinitySvelteKit request-body limit. Accepts bytes or a value with K, M, or G. See Composing and sending.
NODE_ENVweb, workerunsetSet to production for production source deployments. Container images set it automatically.
TZworkerAsia/SeoulTimezone used only when formatting an IMAP cooldown timestamp in worker logs.

Feature configuration

Use the relevant feature page for exact Settings labels, environment names, defaults, and requirements:

FeatureConfiguration page
IMAP and SMTP accountsMail accounts
Authentication providers, passkeys, and sessionsAuthentication
AI and automatic importanceAI features
Public-link and direct attachmentsComposing and sending
OpenPGP private-key storageOpenPGP
Remote-content privacyPrivacy controls
SPF, DKIM, and DMARC trustMail authentication
Push and quiet hoursPush notifications
Outgoing read trackingRead tracking
Public IMAP listenerPublic IMAP proxy
REST API and MCPExternal API and MCP

The feature overview links every feature page, including features with Settings-only configuration and no environment variable.