# Email Delivery: Dev Mailcatcher & Production Mailgun This application uses Symfony Mailer. We separate development and production delivery: - Development: Mailpit (mailcatcher) via SMTP in Docker. - Production: Mailgun via API transport. ## Development (Mailpit) - Service is defined in `compose.override.yaml` as `mailer` (axllent/mailpit). - Ports: - SMTP: 1025 (mapped to host 1025) - Web UI: 8025 (mapped to host 8025) - Default DSN for dev is set in `.env`: ``` MAILER_DSN=smtp://mailer:1025 ``` - Usage: 1. Start stack: `docker-compose up -d` 2. Send an email from the app. 3. Open http://localhost:8025 to view captured emails. ## Production (Mailgun) Use the Mailgun API transport (`symfony/mailgun-mailer` bridge). Do not commit secrets. - Example configuration is in `.env.prod`: ``` MAILER_DSN=mailgun+api://${MAILGUN_API_KEY}:${MAILGUN_DOMAIN}@default?region=eu ``` - `region=eu` is only needed if the Mailgun account/domain was created in Mailgun's EU region (common for `.nl`/EU-based senders). Drop it (or use `region=us`) if the domain lives in the US region. - Provide `MAILGUN_API_KEY` and `MAILGUN_DOMAIN` via: - Real environment variables on the server/container, or - Symfony secrets: `php bin/console secrets:set MAILGUN_API_KEY` (and dump for prod), or - Orchestration secret stores (e.g., Docker/K8s). - The sending domain must be added and DNS-verified (SPF/DKIM/tracking CNAME) in the Mailgun dashboard before production sending will work reliably; unverified domains are rate-limited/sandboxed. ### Notes - No Mailpit container is defined in the base `compose.yaml`, only in `compose.override.yaml`. This ensures it is used in development only. - To test email locally without Docker, you can: - Run Mailpit on your host (ports 1025/8025) and set `MAILER_DSN=smtp://127.0.0.1:1025` in `.env.local`. - If you need to use Mailgun SMTP instead of API, a DSN example: `mailgun+smtp://USERNAME:PASSWORD@default?region=eu` (username/password come from the Mailgun domain's SMTP credentials). - Use `php bin/console app:mail:test you@example.com` to send a quick test email against whatever `MAILER_DSN` is currently configured.