Skip to content

CLI Flags & Environment Variables

Configuration is resolved in this precedence order: CLI flags > environment variables > TOML file > defaults.

Reference

CLI FlagEnvironment VariableDefaultDescription
--bindRUSTMAIL_BIND127.0.0.1IP address to bind SMTP and HTTP listeners to. Docker images default to 0.0.0.0. Use 0.0.0.0 for remote access outside Docker.
--smtp-portRUSTMAIL_SMTP_PORT1025SMTP listener port
--http-portRUSTMAIL_HTTP_PORT8025HTTP and WebSocket port
--db-pathRUSTMAIL_DB_PATH./rustmail.dbPath to the SQLite database file
--retentionRUSTMAIL_RETENTION0Auto-delete messages after N hours. 0 = keep forever.
--max-messagesRUSTMAIL_MAX_MESSAGES0Maximum messages to retain. Oldest are purged when exceeded. 0 = unlimited.
--max-message-sizeRUSTMAIL_MAX_MESSAGE_SIZE10485760Maximum accepted message size in bytes (default: 10 MB).
--smtp-tls-certRUSTMAIL_SMTP_TLS_CERTPath to a PEM certificate used to enable optional SMTP STARTTLS. Must be set together with --smtp-tls-key.
--smtp-tls-keyRUSTMAIL_SMTP_TLS_KEYPath to a PEM private key used to enable optional SMTP STARTTLS. Must be set together with --smtp-tls-cert.
--ephemeralRUSTMAIL_EPHEMERALfalseUse in-memory SQLite. No data is written to disk.
--webhook-urlRUSTMAIL_WEBHOOK_URLHTTP endpoint to POST to on every new message.
--log-levelRUSTMAIL_LOG_LEVELinfoLog verbosity: trace, debug, info, warn, error.
--release-hostRUSTMAIL_RELEASE_HOSTAllowed SMTP target for email release in host:port format (e.g. smtp.example.com:587). Release is disabled unless set.
--configPath to an optional TOML configuration file.

STARTTLS is advertised on the normal SMTP port only when both TLS paths are configured. After the client upgrades the connection, it must send EHLO again before continuing the session.

Examples

sh
# Bind to all interfaces on custom ports
rustmail serve --bind 0.0.0.0 --smtp-port 2525 --http-port 9025

# Keep only the last 24 hours of email, max 1000 messages
rustmail serve --retention 24 --max-messages 1000

# Enable webhook notifications
rustmail serve --webhook-url https://hooks.example.com/email

# Enable optional SMTP STARTTLS on the existing SMTP port
rustmail serve --smtp-tls-cert ./certs/localhost.pem --smtp-tls-key ./certs/localhost-key.pem

# Allow releasing emails to a specific SMTP server
rustmail serve --release-host smtp.mailgun.org:587

Released under the MIT / Apache 2.0 License.