Magento 2 email to a local inbox
To catch Magento 2 email locally, set the mail transport to smtp with host 127.0.0.1 and port 1025, by three bin/magento config:set commands or three environment variables. Order confirmations, invoices and account emails then land in Buggregator, with the HTML preview and raw source. No customer gets them.
Steps
1. Start Buggregator
Port 8000 is the web UI, port 1025 is the SMTP server.
docker run --pull always \
-p 127.0.0.1:8000:8000 \
-p 127.0.0.1:1025:1025 \
ghcr.io/buggregator/server:latest2. Set the SMTP transport
Run three commands in your Magento root.
bin/magento config:set system/smtp/transport smtp
bin/magento config:set system/smtp/host 127.0.0.1
bin/magento config:set system/smtp/port 1025The same settings are in the admin: Stores → Settings → Configuration → Advanced → System → Mail Sending Settings. Also check that Disable Email Communications is set to No there.
3. Or use environment variables
Magento also reads config values from environment variables. Set these in the environment of your PHP process.
CONFIG__DEFAULT__SYSTEM__SMTP__TRANSPORT="smtp"
CONFIG__DEFAULT__SYSTEM__SMTP__HOST="127.0.0.1"
CONFIG__DEFAULT__SYSTEM__SMTP__PORT="1025"4. Use the service name in Docker Compose
If Magento and Buggregator run in the same Compose stack, use the Buggregator service name as the host, for example buggregator, and keep port 1025.
5. Place an order and open the email
Place a test order or create an account in the storefront. Open http://127.0.0.1:8000. You see the rendered HTML with a Desktop / Tablet / Mobile width switcher, the addresses, the attachments and the raw MIME source.
Why it works
With the SMTP transport, Magento hands each email to the mail server at the host and port you set. Buggregator listens on port 1025 with a fake SMTP server that stores each email and shows it in the UI instead of delivering it. Your store code does not change, only the mail settings.
Related tips
- Mail
Catch dev email in docker-compose with one service
Add Buggregator as a service in docker-compose.yml and set your app's mail host to its service name. Every email lands in the UI on port 8000.
- Mail
Check an HTML email at phone width before it ships
Send your app's email to Buggregator on port 1025, then switch the HTML preview between Desktop, Tablet and Mobile width. Nothing reaches a real inbox.
- Mail
WordPress mail from a local site, caught
A small mu-plugin sends WordPress mail to Buggregator on 127.0.0.1:1025, only when WP_ENVIRONMENT_TYPE is local. Nothing reaches real users.
- Mail
Drupal mail to a local inbox
Switch Drupal core to its Symfony mailer and point the SMTP transport at Buggregator on port 1025. Site mail is caught locally, nobody gets it.
Checked on with Buggregator v2.13.0