Email delivery
Mailpit in the default setup
BEANTRAGT_MAIL_MODE selects the delivery path. Without a value, mailpit applies. The bundled .env.example enables the matching Compose profile through COMPOSE_PROFILES. Mailpit captures all messages and shows them at http://localhost:18025. In the default setup nothing is delivered externally.
Existing SMTP server
In .env, BEANTRAGT_MAIL_MODE=smtp enables SMTP mode. compose.mail.yaml then mounts the password as a Docker secret. Mailpit does not start in SMTP mode. A running Mailpit instance is stopped before switching.
docker compose --profile mailpit stop mailpit
| Variable | Meaning |
|---|---|
SMTP_HOST | Host name of the mail server |
SMTP_PORT | Port, default 587 |
SMTP_USER | User name for authentication |
SMTP_FROM | Sender address accepted by the provider |
SMTP_PASSWORD_FILE | Path to a file that contains only the password |
SMTP_EHLO_HOST | Optional, defaults to the domain of the sender address |
msmtp uses STARTTLS with certificate verification. The password file is stored outside the source tree. Read access is restricted to the Drupal user in the container (UID 1000), for example with sudo chown 1000 <file> && sudo chmod 400 <file>. Compose without Swarm does not apply permissions from the secret definition. If the host, user, sender or a readable, non-empty password file is missing, Drupal stops at startup with an error message.
Redirection to a test mailbox
BEANTRAGT_MAIL_REDIRECT_RECIPIENT redirects all messages to a single address. The redirection replaces recipient and reply-to address, removes Cc and Bcc and prefixes the subject with [STAGING→<domain>], using the domain of the original recipient. An invalid value blocks delivery entirely. Without a redirection, the normal delivery path applies.
Verifying delivery
After startup with docker compose up -d --wait --wait-timeout 300, a one-time code is requested at /auth/login for the address of a reachable test mailbox. Signing in with the received code confirms delivery. With an active redirection, the code arrives in the configured target mailbox.