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) #

VariableDefaultDescription
MTA_OUT_RELAY_HOSTunset (direct MX)Relay hostname (e.g., email-smtp.<region>.amazonaws.com). Empty/unset keeps direct MX delivery.
MTA_OUT_RELAY_PORT587Relay TCP port (587 for STARTTLS, 465 for implicit TLS).
MTA_OUT_RELAY_TLSstarttlsTLS mode: starttls or tls (implicit TLS before SMTP banner).
MTA_OUT_RELAY_USERNAMEunsetSMTP AUTH username (e.g., AWS SES SMTP credential username).
MTA_OUT_RELAY_PASSWORD_FILEunset (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_PASSWORDunsetInline password fallback (less secure; MTA_OUT_RELAY_PASSWORD_FILE takes precedence).

Security & Fail-Closed Behavior #

  • Strict TLS >= 1.2 Verification: RelaySmtp enforces TLS 1.2+ with full certificate chain and hostname verification (webpki-roots). Untrusted or mismatched certificates fail closed.
  • No Plaintext Auth: AUTH PLAIN / AUTH LOGIN is never transmitted unless TLS is active (starttls upgraded or tls implicit).
  • File Permission Enforcement: If MTA_OUT_RELAY_PASSWORD_FILE is readable by group or world (mode & 0o077 != 0), mta-out refuses to start (DaemonServer::new fails closed).
  • Secret Redaction: DaemonConfig and RelayAuth redact passwords in debug logs.

Example AWS SES Relay Setup #

  1. 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
  1. 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
  1. Restart mta-out and verify GET :8088/healthz returns 200 OK and a test outbound message clears the queue without 535 authentication 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.