Montara Mail

Configuration

Every environment variable the API reads.

Every setting is an environment variable, or the flag of the same name (/app/api -h). Nothing secret has to be passed as a process argument.

Required

VariableNotes
APP_SECRETAt least 32 characters. Signs tokens and derives the key that encrypts mailbox passwords, OAuth tokens and LLM keys. Rotating it means reconnecting every mailbox and saving the providers again.
DB_DSNPostgreSQL 18 URL. AUTHULA_DATABASE_URL must not be set.

Server

VariableDefaultNotes
ENVproductiondevelopment, staging or production. Only development drops Secure from the session cookie and exempts loopback from rate limits.
DEBUGfalseLogs every query, auth queries with their values; refused in production.
PORT8080
APP_NAMEmontara-mail-agent
SPA_DIR/app/web in the imageThe built web app served at /. Empty serves the API only.
CORS_ALLOWED_ORIGINSemptyComma-separated browser origins allowed to call the API cross-origin. Empty means same-origin only.
TRUSTED_PROXIESemptyIPs or CIDRs of your reverse proxy. The client IP is the rightmost X-Forwarded-For entry that is not one of them.
RATE_LIMIT_EXEMPT_IPSemptyClient IPs the rate limiter skips.
SENTRY_DSNemptyReports panics when set.

Database and boot

VariableDefaultNotes
DB_MAX_OPEN_CONNS, DB_MAX_IDLE_CONNS25The replica's whole budget: Authula's pool takes half, the API the rest.
DB_MAX_IDLE_TIME15m
MIGRATE_ON_BOOTfalseApply the embedded migrations before serving.
SEED_ON_BOOTfalseRun the seeders before serving; needs SUPER_USER. Required by the Community Edition.
SUPER_USERemptyemail:password, password of 12 to 128 characters. See Maintenance.

Sign-in and email

VariableNotes
AUTH_BASE_URLThe public URL of the API, used in email links and OAuth callbacks. Defaults to http://localhost:$PORT.
FROM_ADDRESS, RESEND_API_KEYThe sender (a verified Resend domain) and key for verification, reset and magic-link emails. Required by Cloud; Community may leave them empty, which turns off password reset and magic links.
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETGoogle sign-in; empty disables it. See OAuth apps.

Mail

VariableDefaultNotes
MAIL_SYNC_INTERVAL5mHow often every mailbox syncs. 0 disables the background sync; at least 1m otherwise.
OAUTH_GOOGLE_CLIENT_ID, OAUTH_GOOGLE_CLIENT_SECRETemptyConnect Gmail with OAuth.
OAUTH_MICROSOFT_CLIENT_ID, OAUTH_MICROSOFT_CLIENT_SECRETemptyConnect Outlook with OAuth.
OAUTH_YAHOO_CLIENT_ID, OAUTH_YAHOO_CLIENT_SECRETemptyConnect Yahoo with OAuth.
OAUTH_ZOHO_CLIENT_ID, OAUTH_ZOHO_CLIENT_SECRETemptyConnect Zoho with OAuth.
ALLOW_PRIVATE_HOSTSfalseLets IMAP servers, LLM base URLs and MCP servers that users type in reach loopback or private addresses and use http. Turn on for a local Ollama; keep off when people you don't trust can sign up.

AI and the agent

VariableDefaultNotes
ANTHROPIC_API_KEYemptyFallback model for organizations without their own provider. Without it, those organizations get no AI features.
AGENT_AUTO_DRAFT_INTERVAL1hHow often the agent drafts replies for important unread mail. 0 disables it.
AGENT_AUTO_DRAFT_DAILY_CAP10Drafts each organization may queue per day.
ACTIVITY_LOG_RETENTION8760hHow long activity log entries are kept (they hold IPs and mail subjects). 0 keeps them forever.

On this page