Skip to content

Gateway Configuration

This page documents all configuration options for the VaultSandbox Gateway backend. The gateway is configured exclusively via environment variables.

All environment variables at a glance. See sections below for details.

VariableDefaultDescription
VSX DNS
VSB_VSX_DNS_ENABLEDfalseEnable automatic DNS via vsx.email
Custom Domain
VSB_SMTP_ALLOWED_RECIPIENT_DOMAINSlocalhostDomains to accept emails for
SMTP
VSB_SMTP_HOST0.0.0.0SMTP bind address
VSB_SMTP_PORT25SMTP port
VSB_SMTP_SECUREfalseImmediate TLS (SMTPS)
VSB_SMTP_MAX_MESSAGE_SIZE10485760Max email size (bytes)
VSB_SMTP_MAX_HEADER_SIZE65536Max header size (bytes)
VSB_SMTP_SESSION_TIMEOUT300000Session timeout (ms)
VSB_SMTP_MAX_CONNECTIONS25Max concurrent connections
VSB_SMTP_BANNERVaultSandbox...SMTP greeting
TLS/Certificates
VSB_CERT_ENABLEDfalseEnable Let’s Encrypt
VSB_CERT_EMAILLet’s Encrypt email (optional)
VSB_CERT_DOMAIN(auto)Primary certificate domain
VSB_CERT_STAGINGfalseUse staging environment
VSB_TLS_CERT_PATH Manual cert path
VSB_TLS_KEY_PATHManual key path
VSB_SMTP_TLS_MIN_VERSIONTLSv1.2Minimum TLS version
HTTP Server
VSB_SERVER_PORT80HTTP port
VSB_SERVER_HTTPS_ENABLED(auto)Enable HTTPS server
VSB_SERVER_HTTPS_PORT443HTTPS port
VSB_SERVER_ORIGIN(auto)CORS origin
Local Mode
VSB_GATEWAY_MODElocalOperation mode (see note below)
VSB_LOCAL_API_KEY(auto)API key (min 32 chars)
VSB_LOCAL_API_KEY_STRICTfalseRequire explicit API key
VSB_DATA_PATH/app/dataData directory
VSB_LOCAL_INBOX_DEFAULT_TTL3600Default inbox TTL (seconds)
VSB_LOCAL_INBOX_MAX_TTL604800Max inbox TTL (seconds)
VSB_LOCAL_CLEANUP_INTERVAL300Cleanup interval (seconds)
VSB_LOCAL_ALLOW_CLEAR_ALL_INBOXEStrueAllow DELETE /api/inboxes
Rate Limiting
VSB_THROTTLE_TTL60000API rate limit window (ms)
VSB_THROTTLE_LIMIT500API requests per window
VSB_SMTP_RATE_LIMIT_ENABLEDtrueEnable SMTP rate limiting
VSB_SMTP_RATE_LIMIT_MAX_EMAILS500Max emails per duration
VSB_SMTP_RATE_LIMIT_DURATION900SMTP rate window (seconds)
Clustering
VSB_ORCHESTRATION_ENABLEDfalseEnable distributed mode
VSB_CLUSTER_NAMEdefaultCluster name
VSB_NODE_ID(auto)Node identifier
VSB_CLUSTER_PEERSPeer URLs
Encryption
VSB_ENCRYPTION_ENABLED(mode)Encryption policy for inboxes
Email Authentication
VSB_EMAIL_AUTH_ENABLED(mode)Master switch for all auth checks
VSB_EMAIL_AUTH_SPF_ENABLEDtrueSPF verification
VSB_EMAIL_AUTH_DKIM_ENABLEDtrueDKIM verification
VSB_EMAIL_AUTH_DMARC_ENABLEDtrueDMARC verification
VSB_EMAIL_AUTH_REVERSE_DNS_ENABLEDtrueReverse DNS/PTR verification
VSB_EMAIL_AUTH_INBOX_DEFAULT(mode)Default emailAuth for new inboxes
Webhooks
VSB_WEBHOOK_ENABLEDtrueEnable webhook system
VSB_WEBHOOK_MAX_GLOBAL100Max global webhooks
VSB_WEBHOOK_MAX_INBOX50Max webhooks per inbox
VSB_WEBHOOK_TIMEOUT10000Delivery timeout (ms)
VSB_WEBHOOK_MAX_RETRIES5Max retry attempts
VSB_WEBHOOK_ALLOW_HTTPfalseAllow HTTP URLs (dev only)
VSB_WEBHOOK_REQUIRE_AUTH_DEFAULTfalseDefault requireAuth filter value
Spam Analysis
VSB_SPAM_ANALYSIS_ENABLEDfalseEnable spam analysis (Rspamd)
VSB_RSPAMD_URLlocalhost:11333Rspamd worker API URL
VSB_RSPAMD_TIMEOUT_MS5000Rspamd request timeout (ms)
VSB_RSPAMD_PASSWORDRspamd authentication password
VSB_SPAM_ANALYSIS_INBOX_DEFAULTtrueDefault spam analysis for inboxes
Chaos Engineering
VSB_CHAOS_ENABLEDfalseEnable chaos engineering features
Other
NODE_ENVproductionEnvironment
VSB_SSE_CONSOLE_ENABLEDtrueEnable SSE console
VSB_SDK_DEVELOPMENTfalseEnable dev mode (test endpoints)

You can set environment variables in:

  1. Docker Compose .env file (recommended)
  2. System environment variables
  3. Docker run command with -e flags

The simplest way to run VaultSandbox. With VSX DNS enabled, the gateway automatically discovers your public IP, assigns a domain (e.g., 1mzhr2y.vsx.email), and configures DNS and certificates—no manual setup required.

Description: Enable automatic DNS configuration via vsx.email. When enabled, the gateway auto-discovers your public IP and assigns a subdomain with proper MX records.

Default: false

Example:

Terminal window
VSB_VSX_DNS_ENABLED=true

Requirements:

  • Ports 25, 80, and 443 must be publicly reachable
  • No NAT or firewall blocking inbound connections

What it configures automatically:

  • Domain assignment based on your IP (e.g., 1mzhr2y.vsx.email)
  • DNS records (A and MX)
  • Let’s Encrypt TLS certificates
  • CORS origin

Use your own domain instead of VSX DNS. Requires manual DNS configuration.

Description: Comma-separated list of domains to accept emails for. The gateway will reject emails addressed to other domains.

Default: localhost (dev mode)

Example:

Terminal window
VSB_SMTP_ALLOWED_RECIPIENT_DOMAINS=mail.example.com,sandbox.example.com

Used for:

  • SMTP RCPT TO validation
  • Default domain for ACME certificates (first domain in list)
  • Auto-derived CORS origin (if VSB_SERVER_ORIGIN not set)
  • Dev mode detection: When not set, the gateway enters dev mode with relaxed defaults

Control the behavior of the SMTP server.

Description: The network address the SMTP server binds to.

Default: 0.0.0.0 (All interfaces)

Example:

Terminal window
VSB_SMTP_HOST=127.0.0.1

Description: The port the SMTP server listens on.

Default: 25

Example:

Terminal window
VSB_SMTP_PORT=2525

Notes:

  • Port 25 is required for public internet email delivery.
  • Binding to port 25 typically requires root privileges.

Description: Whether the SMTP server expects an immediate TLS connection (SMTPS). NOTE: This is rarely used for public mail servers, which typically use STARTTLS on port 25.

Default: false

Example:

Terminal window
VSB_SMTP_SECURE=false

Description: Maximum allowed email size in bytes.

Default: 10485760 (10 MB)

Example:

Terminal window
VSB_SMTP_MAX_MESSAGE_SIZE=20971520 # 20MB

Description: Maximum allowed email header block size in bytes. Prevents parser DoS attacks.

Default: 65536 (64 KB)

Example:

Terminal window
VSB_SMTP_MAX_HEADER_SIZE=131072 # 128KB

Description: Timeout for SMTP sessions in milliseconds.

Default: 300000 (5 minutes)

Description: Maximum number of concurrent SMTP connections.

Default: 25

Description: Custom SMTP banner message greeting clients.

Default: VaultSandbox Test SMTP Server (Receive-Only)

Example:

Terminal window
VSB_SMTP_BANNER="My Custom SMTP Gateway"
VariableDefaultDescription
VSB_SMTP_CLOSE_TIMEOUT30000Time in ms to wait before force-closing a connection.
VSB_SMTP_DISABLED_COMMANDSVRFY,EXPN,ETRN,TURNComma-separated list of SMTP commands to disable.
VSB_SMTP_DISABLE_PIPELININGfalseHide PIPELINING capability from clients.
VSB_SMTP_EARLY_TALKER_DELAY300Delay in ms before sending banner to catch “early talker” bots.
VSB_SMTP_MAX_MEMORY_MB500Maximum memory in MB for email storage (memory management).
VSB_SMTP_MAX_EMAIL_AGE_SECONDS0Maximum age of stored emails in seconds (0 = no limit).

Configure TLS/SSL for secure SMTP connections. TLS can be enabled via automatic certificate management (recommended) or manual certificate paths.

If not using automatic certificate management, provide paths to your certificate files:

VariableDefaultDescription
VSB_TLS_CERT_PATH(empty)Path to the TLS certificate file (PEM format).
VSB_TLS_KEY_PATH(empty)Path to the TLS private key file (PEM format).

Note: Both paths must be provided together. For automatic certificate management, use VSB_CERT_ENABLED=true instead.

These settings apply to both manual and automatic TLS configurations:

VariableDefaultDescription
VSB_SMTP_TLS_MIN_VERSIONTLSv1.2Minimum TLS version (TLSv1.2 or TLSv1.3). RFC 8996 compliance.
VSB_SMTP_TLS_CIPHERS(see below)Colon-separated list of allowed cipher suites.
VSB_SMTP_TLS_HONOR_CIPHER_ORDERtruePrefer server cipher order over client preference.
VSB_SMTP_TLS_ECDH_CURVEautoECDH curve configuration for key exchange.

Default Cipher Suites (prioritized for security and performance):

ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305

Configuration for running the gateway in “Local Mode” (standalone), where emails are stored locally and managed via a built-in API.

Description: Operation mode of the gateway.

Default: local

Options:

  • local: Standalone mode. Stores emails locally.
  • backend: Proxies requests to a separate backend service.

Description: API Key for authenticating requests in local mode. If not set, one will be auto-generated and saved to .api-key in the data directory.

Requirements: Minimum 32 characters.

Example:

Terminal window
VSB_LOCAL_API_KEY=your-secure-random-key-minimum-32-chars

Description: If true, disables auto-generation of API keys and forces the server to crash if VSB_LOCAL_API_KEY is not set. Recommended for production.

Default: false

Description: Directory for storing persistent data (API keys, certificates).

Default: /app/data

VariableDefaultDescription
VSB_LOCAL_INBOX_DEFAULT_TTL3600Default time-to-live (seconds) for new inboxes (1 hour).
VSB_LOCAL_INBOX_MAX_TTL604800Maximum allowed TTL (seconds) for any inbox (7 days).
VSB_LOCAL_CLEANUP_INTERVAL300Interval (seconds) for the background cleanup task (5 mins).
VSB_INBOX_ALIAS_RANDOM_BYTES4Number of random bytes for inbox alias generation (4-32). Produces 2x hex characters.
VSB_SMTP_HARD_MODE_REJECT_CODE421SMTP code used when rejecting emails in “hard mode”.
VSB_LOCAL_ALLOW_CLEAR_ALL_INBOXEStrueAllow DELETE /api/inboxes endpoint.

Description: Controls access to the DELETE /api/inboxes endpoint. When set to false, the endpoint returns 403 Forbidden. Useful for shared testing environments to prevent accidental data loss.

Default: true

Example:

Terminal window
VSB_LOCAL_ALLOW_CLEAR_ALL_INBOXES=false

Behavior:

  • true (default): DELETE /api/inboxes works normally, clearing all inboxes
  • false: DELETE /api/inboxes returns 403 Forbidden with message: “Clear all inboxes is disabled (VSB_LOCAL_ALLOW_CLEAR_ALL_INBOXES=false)”

Server Info Response: The current setting is exposed in GET /api/server-info as allowClearAllInboxes:

{
"serverSigPk": "...",
"algs": { ... },
"context": "vaultsandbox:email:v1",
"maxTtl": 604800,
"defaultTtl": 3600,
"sseConsole": false,
"allowClearAllInboxes": true,
"allowedDomains": ["example.com"]
}

Description: Port for the HTTP API server.

Default: 80

Description: Enable the HTTPS server. Defaults to the value of VSB_CERT_ENABLED.

Default: true (when VSB_CERT_ENABLED=true), otherwise false

Description: Port for the HTTPS API server.

Default: 443

Description: Access-Control-Allow-Origin header value (CORS). If not set, auto-derived from the first domain in VSB_SMTP_ALLOWED_RECIPIENT_DOMAINS with appropriate protocol.

Default: Auto-derived (e.g., https://mail.example.com)

Example:

Terminal window
VSB_SERVER_ORIGIN=https://app.example.com
# Or use wildcard for permissive CORS:
VSB_SERVER_ORIGIN=*

Certificate Management (ACME / Let’s Encrypt)

Section titled “Certificate Management (ACME / Let’s Encrypt)”

Variables to configure automatic SSL certificate provisioning.

Description: Enable automatic certificate management.

Default: false

Description: Email address for Let’s Encrypt registration and certificate expiry notifications. Optional - certificates work without it.

Description: Primary domain for the certificate. Defaults to the first domain in VSB_SMTP_ALLOWED_RECIPIENT_DOMAINS.

Description: Comma-separated list of additional domains (Subject Alternative Names) to include in the certificate.

Example:

Terminal window
VSB_CERT_ADDITIONAL_DOMAINS=api.example.com,admin.example.com
VariableDefaultDescription
VSB_CERT_STAGINGfalseUse Let’s Encrypt Staging environment (for testing).
VSB_CERT_CHECK_INTERVAL86400000Interval (ms) to check for renewal (24 hours).
VSB_CERT_RENEW_THRESHOLD_DAYS30Renew certificate if expiring within X days.
VSB_CERT_ACME_DIRECTORYhttps://acme-v02.api.letsencrypt.org/directoryACME directory URL (override for custom CA).
VSB_CERT_PEER_SHARED_SECRET(auto)Shared secret for validating P2P certificate sync requests.

Configuration for running multiple gateway nodes.

Description: Enable distributed coordination (leadership election, lock management).

Default: false

Description: Logical name of the cluster.

Default: default

Description: Unique identifier for this node. If not set, auto-generated from hostname and random bytes.

Default: Auto-generated (e.g., hostname-a1b2c3d4)

Description: Comma-separated list of peer URLs for synchronization.

Example:

Terminal window
VSB_CLUSTER_PEERS=http://node1:80,http://node2:80

If VSB_GATEWAY_MODE is backend, or if VSB_ORCHESTRATION_ENABLED is true, these configure the connection to the upstream service.

VariableDefaultDescription
VSB_BACKEND_URL(empty)URL of the backend service.
VSB_BACKEND_API_KEY(empty)API Key for the backend service.
VSB_BACKEND_REQUEST_TIMEOUT10000Timeout (ms) for backend requests.
VSB_LEADERSHIP_TTL300TTL (seconds) for distributed leadership locks.
VariableDefaultDescription
VSB_THROTTLE_TTL60000Time window in milliseconds (1 minute).
VSB_THROTTLE_LIMIT500Max requests per IP per window.
VariableDefaultDescription
VSB_SMTP_RATE_LIMIT_ENABLEDtrueEnable per-IP rate limiting for SMTP.
VSB_SMTP_RATE_LIMIT_MAX_EMAILS500Max emails allowed per duration.
VSB_SMTP_RATE_LIMIT_DURATION900Duration window in seconds (15 minutes).
VariableDefaultDescription
NODE_ENVproductionApplication environment (development or production).
VSB_SSE_CONSOLE_ENABLEDtrueEnable Server-Sent Events console for real-time logs.
VSB_SDK_DEVELOPMENTfalseEnable development mode. Exposes test endpoints for SDK testing (see below).

Description: Enables development-only features, including a test endpoint for creating emails with controlled authentication results. Useful for SDK development and testing email auth flows without SMTP infrastructure.

Default: false

Example:

Terminal window
VSB_SDK_DEVELOPMENT=true

What it enables:

  • POST /api/test/emails - Create test emails with controlled SPF/DKIM/DMARC results

See the SDK Test Specification for endpoint details and usage examples.

Control whether emails are stored encrypted or in plain text.

Description: Encryption policy for email storage. Controls whether inboxes use quantum-safe encryption (ML-KEM-768 + AES-256-GCM) or store emails in plain text.

Default:

  • disabled in dev mode (plain by default, but can request encrypted inboxes)
  • always in production mode (secure by default)

Values:

PolicyDefault EncryptionPer-Inbox Override
alwaysEncryptedNo - all inboxes encrypted
enabledEncryptedYes - can request plain
disabledPlainYes - can request encrypted
neverPlainNo - all inboxes plain

Example:

Terminal window
# Default: all inboxes encrypted, no override allowed
VSB_ENCRYPTION_ENABLED=always
# Encrypted by default, but clients can request plain inboxes
VSB_ENCRYPTION_ENABLED=enabled
# Plain by default, but clients can request encrypted inboxes
VSB_ENCRYPTION_ENABLED=disabled
# All inboxes plain, no override allowed
VSB_ENCRYPTION_ENABLED=never

API Impact:

  • GET /api/server-info returns encryptionPolicy field with the current policy
  • POST /api/inboxes accepts optional encryption parameter ("encrypted" or "plain") when policy allows overrides
  • Response includes encrypted boolean indicating actual encryption state
  • When encrypted, clientKemPk is required in inbox creation; serverSigPk is returned in response

Control SPF, DKIM, DMARC, and reverse DNS validation for incoming emails.

Description: Master switch for all email authentication checks. When false, all checks are skipped globally and return status: 'skipped'.

Default:

  • false in dev mode (when VSB_SMTP_ALLOWED_RECIPIENT_DOMAINS is not set)
  • true in production mode (when a domain is configured)

Example:

Terminal window
VSB_EMAIL_AUTH_ENABLED=false # Skip all auth checks globally
VSB_EMAIL_AUTH_ENABLED=true # Enable auth checks (override dev mode default)

When the master switch is enabled, each authentication method can be enabled or disabled independently:

VariableDefaultDescription
VSB_EMAIL_AUTH_SPF_ENABLEDtrueSPF (Sender Policy Framework) verification
VSB_EMAIL_AUTH_DKIM_ENABLEDtrueDKIM signature verification
VSB_EMAIL_AUTH_DMARC_ENABLEDtrueDMARC policy verification
VSB_EMAIL_AUTH_REVERSE_DNS_ENABLEDtrueReverse DNS (PTR record) verification

Example:

Terminal window
# Disable only DKIM checks
VSB_EMAIL_AUTH_DKIM_ENABLED=false
# Disable reverse DNS checks
VSB_EMAIL_AUTH_REVERSE_DNS_ENABLED=false

Description: Default emailAuth setting for new inboxes when clients don’t specify a preference.

Default:

  • false in dev mode (no auth checks on new inboxes by default)
  • true in production mode (auth checks enabled by default)

Example:

Terminal window
# New inboxes have email auth disabled by default
VSB_EMAIL_AUTH_INBOX_DEFAULT=false

Behavior Hierarchy:

  1. If VSB_EMAIL_AUTH_ENABLED=false → ALL checks skipped globally (inbox setting ignored)
  2. If inbox has emailAuth: false → Checks skipped for that inbox
  3. Otherwise → Individual VSB_EMAIL_AUTH_*_ENABLED variables control each check

API Impact:

  • POST /api/inboxes accepts optional emailAuth boolean to override the default per inbox
  • GET /api/inboxes/:email/emails returns authResults with status: 'skipped' when checks are disabled
  • GET /api/server-info does not expose the default (clients should omit the field to use server default)

Configure real-time HTTP notifications for email events. See the Webhooks documentation for full details on usage.

VariableDefaultDescription
VSB_WEBHOOK_ENABLEDtrueEnable/disable the webhook system
VSB_WEBHOOK_MAX_GLOBAL100Maximum global webhooks per account
VSB_WEBHOOK_MAX_INBOX50Maximum webhooks per inbox
VSB_WEBHOOK_TIMEOUT10000Delivery timeout in milliseconds
VSB_WEBHOOK_MAX_RETRIES5Maximum retry attempts before disabling
VSB_WEBHOOK_ALLOW_HTTPfalseAllow HTTP URLs (development only)
VSB_WEBHOOK_REQUIRE_AUTH_DEFAULTfalseDefault requireAuth filter value

Description: Master switch for the webhook system. When false, no webhooks are dispatched.

Default: true

Description: Allow non-HTTPS webhook URLs. Only enable for local development.

Default: false

Description: Default value for the requireAuth filter option when creating webhooks. When true, webhooks only fire for emails that pass SPF/DKIM/DMARC authentication.

Default: false

Configure Rspamd integration for spam detection. See the Spam Analysis documentation for full details on setup and usage.

VariableDefaultDescription
VSB_SPAM_ANALYSIS_ENABLEDfalseEnable spam analysis globally
VSB_RSPAMD_URLhttp://localhost:11333Rspamd worker API URL
VSB_RSPAMD_TIMEOUT_MS5000Request timeout in milliseconds
VSB_RSPAMD_PASSWORDPassword for Rspamd authentication (optional)
VSB_SPAM_ANALYSIS_INBOX_DEFAULTtrueDefault spam analysis setting for new inboxes

Configure chaos engineering features for testing application resilience. See the Chaos Engineering documentation for full details on chaos types and API usage.

Description: Master switch for chaos engineering features. When false, all chaos-related API endpoints return 403 Forbidden and chaos configurations are ignored.

Default: false

Example:

Terminal window
VSB_CHAOS_ENABLED=true

What it enables:

  • GET /api/inboxes/:email/chaos - Get inbox chaos configuration
  • POST /api/inboxes/:email/chaos - Update inbox chaos configuration
  • DELETE /api/inboxes/:email/chaos - Disable chaos for an inbox
  • chaos field in POST /api/inboxes request body
  • Chaos evaluation during SMTP email processing

Used for quantum-safe signing of responses (ML-DSA-65 digital signatures).

VariableDefaultDescription
VSB_SERVER_SIGNATURE_SECRET_KEY_PATH(empty)Path to the secret key file (raw binary, 4032 bytes).
VSB_SERVER_SIGNATURE_PUBLIC_KEY_PATH(empty)Path to the public key file (raw binary, 1952 bytes).

Notes:

  • Both paths must be provided together, or neither (for ephemeral keys).
  • If not provided, ephemeral keys are generated on startup (keys change on restart).
  • For production, use persistent keys to maintain signature verification across restarts.