Local Development Setup
Local Development Setup
Section titled “Local Development Setup”This guide covers running VaultSandbox Gateway on your local machine for development purposes. This setup uses HTTP only, requires no public IP address, and runs entirely on localhost.
Prerequisites
Section titled “Prerequisites”- Docker Engine 20.10+ and Docker Compose v2.0+
- Ports 2525 (SMTP) and 8080 (HTTP) available on localhost
Docker Compose Configuration
Section titled “Docker Compose Configuration”Create a docker-compose.yml file:
services: gateway: image: vaultsandbox/gateway:latest ports: - '127.0.0.1:2525:25' # SMTP - '127.0.0.1:8080:80' # HTTP API + Web UI volumes: - gateway-data:/app/data
volumes: gateway-data:That’s it — zero environment variables needed for local development. The gateway automatically detects dev mode and configures sensible defaults:
- Allowed domains:
localhost - Email authentication: Disabled (SPF/DKIM/DMARC checks skipped)
- API key: Auto-generated and displayed in logs
Starting the Gateway
Section titled “Starting the Gateway”# Start the gatewaydocker compose up -d
# View logsdocker compose logs -f gateway
# Check health statuscurl http://localhost:8080/healthRetrieving the API Key
Section titled “Retrieving the API Key”The API key is auto-generated on first startup and persisted to a file. Retrieve it with:
docker compose exec gateway cat /app/data/.api-key; echoAlternatively, set a fixed API key by adding to your docker-compose.yml:
environment: VSB_LOCAL_API_KEY: 'your-api-key-at-least-32-characters-long'Accessing the Gateway
Section titled “Accessing the Gateway”| Service | URL / Address |
|---|---|
| Web UI | http://localhost:8080/app |
| API | http://localhost:8080/api |
| SMTP | localhost:2525 |
Configuring Your Application
Section titled “Configuring Your Application”Point your application’s SMTP configuration to the local gateway:
# Environment variables exampleSMTP_HOST=localhostSMTP_PORT=2525SMTP_SECURE=falseNode.js Example (Nodemailer)
Section titled “Node.js Example (Nodemailer)”const nodemailer = require('nodemailer');const { VaultSandboxClient } = require('@vaultsandbox/client');
// Create VaultSandbox clientconst client = new VaultSandboxClient({ url: 'http://localhost:8080', apiKey: 'YOUR_API_KEY',});
// Create an inbox to receive emailsconst inbox = await client.createInbox();
// Configure Nodemailer to send through local gatewayconst transporter = nodemailer.createTransport({ host: 'localhost', port: 2525, secure: false,});
// Send a test email to the inbox's generated addressawait transporter.sendMail({ from: 'test@example.com', to: inbox.emailAddress, subject: 'Test Email', text: 'Hello from local development!',});
// Wait for the email to arriveconst email = await inbox.waitForEmail({ timeout: 5000 });console.log('Received:', email.subject);
// Cleanupawait inbox.delete();Using the API
Section titled “Using the API”With your API key, you can query captured emails.
# List all emailscurl -H "X-API-Key: YOUR_API_KEY" http://localhost:8080/api/emails
# Get a specific emailcurl -H "X-API-Key: YOUR_API_KEY" http://localhost:8080/api/emails/{id}See the API Reference for complete documentation.
Enabling Local HTTPS (Optional)
Section titled “Enabling Local HTTPS (Optional)”If you need to test HTTPS locally (e.g., for secure cookies or service workers), we recommend using mkcert — a simple tool for making locally-trusted development certificates.
Install mkcert
Section titled “Install mkcert”# macOSbrew install mkcert
# Linuxsudo apt install libnss3-toolscurl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"chmod +x mkcert-v*-linux-amd64sudo mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert
# Windows (with Chocolatey)choco install mkcertGenerate Certificates
Section titled “Generate Certificates”# Install the local CA (one-time setup)mkcert -install
# Generate certificates for localhostmkcert -cert-file localhost.pem -key-file localhost-key.pem localhost 127.0.0.1 ::1
# Ensure the key file is readable by the Docker containerchmod 644 localhost-key.pemUse with VaultSandbox Gateway
Section titled “Use with VaultSandbox Gateway”services: gateway: image: vaultsandbox/gateway:latest ports: - '127.0.0.1:2525:25' # SMTP - '127.0.0.1:8080:80' # HTTP - '127.0.0.1:8443:443' # HTTPS environment: VSB_CERT_ENABLED: 'true' VSB_TLS_CERT_PATH: '/certs/localhost.pem' VSB_TLS_KEY_PATH: '/certs/localhost-key.pem' volumes: - gateway-data:/app/data - ./localhost.pem:/certs/localhost.pem:ro - ./localhost-key.pem:/certs/localhost-key.pem:ro
volumes: gateway-data:The mkcert CA is automatically trusted by your system browsers and tools after running mkcert -install.
Stopping the Gateway
Section titled “Stopping the Gateway”# Stop and remove containersdocker compose down
# Stop and remove containers AND datadocker compose down -vTroubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”If ports 2525 or 8080 are already in use, modify the port mappings:
ports: - '127.0.0.1:2526:25' # Use port 2526 instead - '127.0.0.1:8081:80' # Use port 8081 insteadConnection Refused
Section titled “Connection Refused”Ensure the container is running and healthy:
docker compose psdocker compose logs gatewayEmails Not Appearing
Section titled “Emails Not Appearing”- Verify your application is sending to
localhost:2525 - Check the gateway logs for incoming connections
- Ensure the recipient address ends with
@localhost(the default in dev mode)
Next Steps
Section titled “Next Steps”- Gateway Configuration - Full environment variable reference
- Web UI Guide - Browse and inspect captured emails
- Node.js Client - Programmatic email verification in tests
- Docker Compose Setup - Production deployment with TLS