AWS SES & SMTP Relay Configuration #
By default, mta-out delivers outbound mail via direct MX resolution (DirectSmtp / PoolRoutedSmtp). On cloud VMs where outbound TCP port 25 is blocked by default (such as standard AWS EC2 instances), configure mta-out in SMTP Relay (SmartHost) mode using RelaySmtp to relay outbound mail through AWS SES (email-smtp.<region>.amazonaws.com:587) or another authenticated relay.
Environment Variables (mta-out) #
| Variable | Default | Description |
|---|---|---|
MTA_OUT_RELAY_HOST | unset (direct MX) | Relay hostname (e.g., email-smtp.<region>.amazonaws.com). Empty/unset keeps direct MX delivery. |
MTA_OUT_RELAY_PORT | 587 | Relay TCP port (587 for STARTTLS, 465 for implicit TLS). |
MTA_OUT_RELAY_TLS | starttls | TLS mode: starttls or tls (implicit TLS before SMTP banner). |
MTA_OUT_RELAY_USERNAME | unset | SMTP AUTH username (e.g., AWS SES SMTP credential username). |
MTA_OUT_RELAY_PASSWORD_FILE | unset (preferred) | Path to file containing the SMTP AUTH password. Must have owner-only Unix permissions (mode & 0o077 == 0, e.g., 0600 or 0400). |
MTA_OUT_RELAY_PASSWORD | unset | Inline password fallback (less secure; MTA_OUT_RELAY_PASSWORD_FILE takes precedence). |
Security & Fail-Closed Behavior #
- Strict TLS >= 1.2 Verification:
RelaySmtpenforces TLS 1.2+ with full certificate chain and hostname verification (webpki-roots). Untrusted or mismatched certificates fail closed. - No Plaintext Auth:
AUTH PLAIN/AUTH LOGINis never transmitted unless TLS is active (starttlsupgraded ortlsimplicit). - File Permission Enforcement: If
MTA_OUT_RELAY_PASSWORD_FILEis readable by group or world (mode & 0o077 != 0),mta-outrefuses to start (DaemonServer::newfails closed). - Secret Redaction:
DaemonConfigandRelayAuthredact passwords in debug logs.
Example AWS SES Relay Setup #
- Create a permission-restricted credential file on the host:
bash
install -m 0600 /dev/null /var/lib/tsubame/cell/credentials/ses-relay-password
# Write your SES SMTP password into the file without trailing whitespace- Add the relay variables to
infra/deploy/cell/.env:
bash
MTA_OUT_RELAY_HOST=email-smtp.<your-aws-region>.amazonaws.com
MTA_OUT_RELAY_PORT=587
MTA_OUT_RELAY_TLS=starttls
MTA_OUT_RELAY_USERNAME=<YOUR_SES_SMTP_USERNAME>
MTA_OUT_RELAY_PASSWORD_FILE=/run/secrets/ses-relay-password- Restart
mta-outand verifyGET :8088/healthzreturns200 OKand a test outbound message clears the queue without535authentication errors.
TIP
Verify your sender domains and DKIM records in AWS SES as well as in TsubameMail so upstream SES does not reject messages from custom tenant domains.