Prepared Settings
Prepared configuration allows you to pre-configure EmailEngine settings, access tokens, and license keys before the application starts. This is essential for automated deployments, CI/CD pipelines, and containerized environments where manual configuration is impractical.
Overview
EmailEngine supports three types of prepared configuration:
- Prepared Settings - Runtime configuration (webhooks, OAuth2, etc.)
- Prepared Access Tokens - API authentication tokens
- Prepared License Keys - License activation
All prepared configuration is applied on every application startup. This means settings will be overwritten each time EmailEngine starts, ensuring your environment configuration always takes precedence.
Use Cases
Automated Deployments:
- Docker/Kubernetes deployments
- Infrastructure as Code (Terraform, Ansible)
- CI/CD pipelines
Testing:
- End-to-end automated testing
- Integration test environments
- Staging environment setup
Multi-Environment Setup:
- Development, staging, production configs
- Multi-tenant deployments
- Rapid environment provisioning
Prepared Settings
Pre-configure runtime settings that would normally be set via the Settings API or web interface.
What Can Be Pre-Configured
Any setting available via the /v1/settings API endpoint:
- Webhook URLs and event filters
- SMTP server configuration (built-in SMTP server)
- Service URL and base URLs
- Tracking settings (clicks, opens)
- Logging configuration
- Proxy settings
- IMAP proxy configuration
- UI branding and locale settings
Configuration Methods
- Environment Variable
- Command-Line
- Docker
- Docker Compose
Set the EENGINE_SETTINGS environment variable with a JSON string:
export EENGINE_SETTINGS='{"webhooks": "https://webhook.site/abc123","webhookEvents":["messageNew"]}'
emailengine
Use the --settings flag:
emailengine --settings='{"webhooks": "https://your-app.com/webhook","webhookEvents":["messageNew"]}'
Single-line environment variable:
ENV EENGINE_SETTINGS='{"webhooks":"https://your-app.com/webhook","webhookEvents":["messageNew","messageSent"]}'
Multi-line YAML format (recommended):
version: '3.8'
services:
emailengine:
image: postalsys/emailengine:latest
environment:
EENGINE_SETTINGS: >
{
"webhooks": "https://your-app.com/webhook",
"webhookEvents": [
"messageNew",
"messageDeleted",
"messageSent",
"messageDeliveryError"
],
"notifyText": "EmailEngine notification",
"serviceUrl": "https://emailengine.example.com"
}
Using external file:
services:
emailengine:
image: postalsys/emailengine:latest
env_file:
- ./config/emailengine.env
# config/emailengine.env
EENGINE_SETTINGS={"webhooks":"https://your-app.com/webhook","webhookEvents":["messageNew"]}
Examples
Basic webhook configuration:
EENGINE_SETTINGS='{
"webhooks": "https://your-app.com/webhook",
"webhookEvents": ["messageNew", "messageSent"]
}'
Complete configuration:
EENGINE_SETTINGS='{
"webhooks": "https://your-app.com/webhook",
"webhookEvents": [
"messageNew",
"messageDeleted",
"messageSent",
"messageDeliveryError"
],
"notifyText": "New email notification",
"notifyTextSize": 100,
"serviceUrl": "https://emailengine.example.com"
}'
SMTP server and tracking:
EENGINE_SETTINGS='{
"smtpServerEnabled": true,
"smtpServerPort": 2525,
"smtpServerHost": "0.0.0.0",
"smtpServerAuthEnabled": true,
"trackClicks": true,
"trackOpens": true
}'
OAuth2 provider credentials (Gmail, Outlook) should be configured using the OAuth2 Applications API (/v1/oauth2) rather than the settings endpoint. The legacy settings like gmailClientId are deprecated.
Validation
Settings are validated on startup. If validation fails, the application won't start:
Error: Invalid settings configuration
- webhooks: must be a valid URL
- webhookEvents: must be an array
Check your JSON syntax and setting values if you encounter errors.
Updating Prepared Settings
Prepared settings are applied on every startup, overwriting existing values. To update:
- Update the
EENGINE_SETTINGSenvironment variable and restart EmailEngine - Or use the Settings API for runtime changes (will be overwritten on next restart if also defined in
EENGINE_SETTINGS)
Update settings via API:
# Update specific setting
curl -X POST http://localhost:3000/v1/settings \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"webhooks": "https://new-webhook-url.com/webhook",
"webhookEvents": ["messageNew", "messageSent"]
}'
# Clear specific setting by setting to null
curl -X POST http://localhost:3000/v1/settings \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"webhooks": null}'
See Also
- Prepared Access Tokens - Pre-configure API access tokens
- Prepared License - Pre-configure license keys
- Environment Variables - Complete environment variable reference
- Settings API - Programmatic settings management