Docker Compose Outbound SMTP Relay: Zero-MTA Email Dispatch
Dispatch transactional emails from containerized microservices without running heavy Postfix containers or opening blocked port 25. Authenticated port 587 TLS with automatic Dual-DKIM signing.
Docker Compose Configuration
version: '3.8'
services:
web-app:
image: your-app-image:latest
restart: unless-stopped
ports:
- "3000:3000"
environment:
# SadaSend ESMTP Submission Relay (RFC 5321 / RFC 3207)
- SMTP_HOST=smtp.sadasend.com
- SMTP_PORT=587
- SMTP_SECURE=false # STARTTLS upgrades to TLS 1.3
- SMTP_USER=sadasend
- SMTP_PASS=${SADASEND_API_KEY}
- EMAIL_FROM=alerts@yourdomain.com
env_file:
- .env.productionConfigure Containerized Mail in 4 Steps
Generate Token-Scoped API Key
In your SadaSend Dashboard (/app/keys), mint a dedicated API key restricted to outbound email dispatch for your production containers.
Define Secure Environment Secrets
Store your credentials in .env.production and add it to your .gitignore to prevent leaking API keys into public git repositories.
SADASEND_API_KEY=sk_live_981a7b2c01ef4388
SMTP_HOST=smtp.sadasend.com
SMTP_PORT=587
SMTP_USER=sadasendInject Variables into docker-compose.yml
Reference the environment variables in your service definitions. Your containerized application connects directly over port 587.
Deploy Containers and Verify Transport
Spin up your compose stack with docker compose up -d. SadaSend automatically applies Dual-DKIM signatures to all outbound MIME envelopes.
Dispatch Code Recipes for Microservices
Clean, zero-bloat implementations using native language libraries inside your containers.
import nodemailer from 'nodemailer';
export const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST || 'smtp.sadasend.com',
port: Number(process.env.SMTP_PORT) || 587,
secure: false, // true for 465, false for 587 (STARTTLS)
auth: {
user: process.env.SMTP_USER || 'sadasend',
pass: process.env.SADASEND_API_KEY,
},
});
export async function sendAlert(to: string, subject: string, html: string) {
return transporter.sendMail({
from: process.env.EMAIL_FROM || 'alerts@yourdomain.com',
to,
subject,
html,
});
}SadaSend ESMTP Relay vs. Self-Hosted Postfix Containers
| Relay Approach | Setup Complexity | Port 25 VPS Block | DKIM Maintenance | Overage Cost Risk |
|---|---|---|---|---|
SadaSend ESMTP Relay | 1 minute (Env vars only) | Unaffected (Port 587 TLS) | Automated Dual-DKIM | $0 default ceiling |
Self-Hosted Postfix Container | Complex (MTA configs, SASL, ports) | Blocked on 95% of Cloud VPS | Manual OpenDKIM keys & cron | Infinite retry loops |
SendGrid SMTP Integration | Moderate (Account verification) | Port 587 supported | Single RSA 2048 only | Unmetered overages billed |
AWS SES SMTP Interface | High (IAM, VPC NAT gateways) | Port 587 supported | Easy DKIM (RSA) | Auto-billed per message |
Frequently Asked Questions
Clean Outbound Email for Docker Compose
Stop struggling with blocked port 25 and fragile Postfix containers. Connect over port 587 with automatic Dual-DKIM signing and zero credit card required.