Skip to main content

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.

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  -p 127.0.0.1:1025:1025 \
  ghcr.io/buggregator/server:latest

2. Set the SMTP transport

Run three commands in your Magento root.

bash
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 1025

The 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.

dotenv
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.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you