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_DOMAINSDomains 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_SMTP_TLS_CERT_PATHManual cert path
VSB_SMTP_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)
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
Other
NODE_ENVproductionEnvironment
VSB_SSE_CONSOLE_ENABLEDtrueEnable SSE console
VSB_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. Required when not using VSX DNS.

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)

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_SMTP_TLS_CERT_PATH(empty)Path to the TLS certificate file (PEM format).
VSB_SMTP_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”.

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_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_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.

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.