SMTP — Email Testing
Your app sends emails — registration confirmations, password resets, notifications. You need to verify they look correct without actually delivering them. Buggregator includes a fake SMTP server: point your app's mail config at port 1025 and every email shows up in the UI. No Mailhog, no Mailtrap, no external services — just another module in the same Buggregator instance where you already see your logs and exceptions.

Use cases
- Email template testing — preview HTML emails with a desktop/mobile viewport switcher to check responsive layouts.
- Transactional email verification — make sure the right recipients, subject, and content are set before going to production.
- Attachment testing — verify that attachments are generated correctly and can be downloaded.
- All in one place — see emails in the same UI as your exceptions, logs, and dumps.
What you see in the UI
- HTML preview — rendered email with desktop/mobile device viewport switcher.
- Plain text — the plain text version of the email.
- Addresses — From, To, CC, BCC, Reply-To organized by type.
- Attachments — download or preview any attached file. Inline images display correctly in the HTML preview.
- Raw source — the raw MIME source for debugging encoding or header issues.
- Other versions — Apple Watch, AMP, calendar invites and delivery reports, each in its own tab, see Other versions of an email.
Other versions of an email
An email can carry more than an HTML and a plain-text body. Example: an order email from Apple Mail also has a short version for the Apple Watch, and a Google Calendar invite has the event itself as text/calendar. Since server 2.14.0, Buggregator keeps these versions and shows each in its own tab. Nothing to set up: send the email as usual.
| Part in the email | Tab |
|---|---|
text/watch-html | Apple Watch: shown at phone width, with a Source view |
text/x-amp-html | AMP: a static view, AMP scripts do not run; with a Source view |
text/calendar, application/ics | Calendar |
message/delivery-status | Delivery status (a bounce report) |
message/disposition-notification | Read receipt |
text/rfc822-headers | Original headers |
text/enriched, text/richtext, text/markdown | Enriched text, Rich text, Markdown |
any other text/* | the media type, e.g. text/x-custom |
The tabs come after the main preview and before Raw. The email's info also lists them under Other versions.
Calendar invites
When an email has a text/calendar part or an .ics attachment, an invite card shows above the email: what, when, where, the organizer and the guests with their answers (Accepted, Declined, Maybe, No answer). Example: your app invites to «Release sync» on 1 December 2026 from 09:00 to 09:30 UTC. A viewer in Berlin sees «Tue, 1 Dec 2026, 10:00 – 10:30 (CET)», the organizer and who has answered.
- The time is shown in your time zone. When the invite names a zone the server does not know (Outlook names such as
W. Europe Standard Time), the card shows the sender's time with that name. - A cancelled invite (
METHOD:CANCELorSTATUS:CANCELLED) is struck out and marked Cancelled. - The card reads only the first event of the invite. A link in the invite is clickable only when it is
httporhttps.
In the list
The email list marks emails with Watch, AMP, Invite or Cancelled, and shows the invite's title and time in one line.
Limits
- Only emails received after the upgrade have these tabs. Older emails stay as they were.
- Each version is kept up to 1 MB. A longer one is cut, the tab says so, and the whole email stays in Raw.
- The
textandhtmlfields do not change: codes, links andbody_containsread them as before.
Configuration
Point your app's SMTP settings to 127.0.0.1:1025. A user name and password are optional: Buggregator accepts any. The user name can choose the project.
In Docker Compose, replace
127.0.0.1with the Buggregator service name (e.g.,buggregator).
Laravel
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025Spiral Framework
MAILER_DSN=smtp://127.0.0.1:1025Symfony
MAILER_DSN=smtp://127.0.0.1:1025Magento 2
CONFIG__DEFAULT__SYSTEM__SMTP__TRANSPORT="smtp"
CONFIG__DEFAULT__SYSTEM__SMTP__HOST="127.0.0.1"
CONFIG__DEFAULT__SYSTEM__SMTP__PORT="1025"or via CLI:
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 1025WordPress
Save to the mu-plugins directory (e.g., smtp.php):
<?php
/**
* Plugin Name: MU Buggregator SMTP
*/
if (! defined('WP_ENVIRONMENT_TYPE') || 'local' !== WP_ENVIRONMENT_TYPE) {
return;
}
add_action( 'phpmailer_init', function( $phpmailer ) : void {
$phpmailer->isSMTP();
$phpmailer->Host = '127.0.0.1';
$phpmailer->Port = 1025;
} );Any other app
Any application that can send email via SMTP works. Set host to 127.0.0.1 and port to 1025.
Projects
Since server v2.5.0, the SMTP user name chooses the project. The password can be anything. Mail sent without a user name lands in default.
For example, mail sent with the user name shop lands in the project shop:
# Laravel
MAIL_USERNAME=shop
MAIL_PASSWORD=any
# Symfony, Spiral
MAILER_DSN=smtp://shop:any@127.0.0.1:1025A user name like shop@example.com works too: the part before @ is the project key.
Send to a real inbox
Sometimes you want to see a caught email in a real mail client: how Gmail or Outlook shows it, whether a link works on your phone. Since server 2.13.0 the button Send to inbox on an email's page sends that one message on through a real SMTP server you set up. Nothing is forwarded by itself: only the message you send, only to the addresses you type.
Setup
Add the outgoing server to buggregator.yaml. Example for Gmail (it needs an app password):
smtp_relay:
host: smtp.gmail.com
port: 587
tls: starttls
username: me@gmail.com
password_file: /run/secrets/smtp_password
allowed_recipients: ["me@gmail.com", "*@mycompany.com"]Or the same with environment variables:
SMTP_RELAY_HOST=smtp.gmail.com \
SMTP_RELAY_USERNAME=me@gmail.com \
SMTP_RELAY_PASSWORD=app-password \
SMTP_RELAY_ALLOWED_RECIPIENTS=me@gmail.com,*@mycompany.com \
./buggregator| Key | Environment variable | Default |
|---|---|---|
host | SMTP_RELAY_HOST | empty: the button is off |
port | SMTP_RELAY_PORT | 587 for starttls, 465 for tls, 25 for none |
tls | SMTP_RELAY_TLS | starttls; or tls, none |
username, password | SMTP_RELAY_USERNAME, SMTP_RELAY_PASSWORD | no login |
password_file | SMTP_RELAY_PASSWORD_FILE | read the password from a file (Docker or Kubernetes secret) |
from | SMTP_RELAY_FROM | the sender address given to the server; empty: the login if it is an address, else the email's From |
allowed_recipients | SMTP_RELAY_ALLOWED_RECIPIENTS (comma-separated) | who may get mail, see below |
insecure_skip_verify | SMTP_RELAY_INSECURE_SKIP_VERIFY | false; true accepts any certificate. With a login, only for a relay on this machine: to a remote relay it then refuses to send |
Environment variables win over the file. The password is never sent over an unencrypted connection to another machine: use starttls or tls.
allowed_recipients takes patterns, case does not matter: me@gmail.com is one address, *@mycompany.com is everyone at that domain (not its subdomains).
Who can send
Without login (SSO off), two rules protect you:
- The button works only from this machine, with the UI opened as
localhostor127.0.0.1. From another machine, from Docker, or through a proxy that addsX-Forwarded-For,X-Forwarded-Host,X-Real-IPorForwarded, you get «without auth, release works only from this machine». A proxy on this machine that adds none of these headers looks local, so the button works through it. Behind any proxy, turn on SSO. allowed_recipientsmust be set, and each pattern must name a real domain.*,*@*or*@*.comwould let anyone mail anyone, so they turn the button off. One such pattern turns off the whole list.
With SSO on, any signed-in user can send from anywhere. allowed_recipients is optional; without it any address is allowed.
In both cases another web page open in the same browser cannot send: it gets an error. A request without a browser's Origin, like curl or a script, is not blocked by this: without SSO it works from this machine, with SSO it needs a token.
What is sent
In the dialog, type the addresses to send to. The email's original recipients never get it.
- By default the message goes exactly as it was caught: same headers (the original To and Cc stay in it), same attachments.
- Check Put these addresses in To to replace To with your addresses and drop Cc. The rest stays as it was.
Limits: 20 addresses per email, 10 emails a minute for the whole server.
Settings › Email relay shows whether sending is on, the server, the allowed recipients and, when it is off, why.
Testing API
End-to-end tests often need to check an email: "did the reset mail arrive, and what is the code in it?" The testing API answers that over plain HTTP. Example: your test clicks "Forgot password", waits for the email to alice@example.com, and reads the 6-digit code from it.
All routes below need the same login as the rest of /api when SSO is on: send the X-Auth-Token header (see Calling the API from scripts).
| Method | Path | Answer |
|---|---|---|
GET | /api/smtp/cursor | {"cursor": "2026-11-07T08:30:09.123456789Z"}: the server time now |
GET | /api/smtp/messages | messages that match the filters: {"data": [event, …], "meta": {"total", "limit", "offset"}} |
GET | /api/smtp/messages/wait | the first message that matches, as soon as there is one; 408 on timeout |
GET | /api/smtp/stats?project= | {"count": 3, "last_received_at": "2026-11-07T08:30:09Z"}; last_received_at is null with no mail |
DELETE | /api/smtp/messages?project= | deletes the messages (of one project, or all): {"status": true} |
GET | /api/smtp/message/{uuid}/raw | the original message source (Content-Type: message/rfc822) |
GET | /api/smtp/message/{uuid}/links | links from the HTML and text parts: {"data": [{"url", "text", "source"}]}; source is html or text |
GET | /api/smtp/message/{uuid}/codes?pattern= | codes found in the text and HTML parts: {"data": ["482913"], "pattern": "\\b\\d{4,8}\\b"} |
An event is a normal Buggregator event: uuid, type (smtp), timestamp, project and payload. The payload has subject, from, to, cc, reply_to (lists of {"email", "name"}), bcc, text, html and raw. Since server 2.14.0, two optional fields, absent on an ordinary email:
parts: the other versions,[{"type", "label", "content", "size", "truncated"}]in message order.sizeis in bytes before the 1 MB cut;truncatedistruewhen the content was cut.calendar: the invite,{"method", "summary", "start", "end", "tz", "all_day", "location", "description", "url", "status", "uid", "sequence", "rrule", "organizer": {"name", "email"}, "attendees": [{"name", "email", "status", "role"}]}.startandendare RFC 3339 when the zone is known (2026-12-01T09:00:00Z); a local time plustzwhen it is not (2026-12-03T14:00:00,W. Europe Standard Time); a date whenall_dayistrue.
The MCP tool event_get returns the same payload, so an AI assistant sees the other versions and the invite too.
Errors are {"message", "code"}. An unknown uuid gets 404.
Filters
/messages and /messages/wait take the same filters. Every filter you pass must match.
| Parameter | Matches when |
|---|---|
to, from, cc | any address or name in that field contains the value, ignoring case (to=alice finds Alice <alice@example.com>) |
subject | the subject is exactly the value |
subject_contains | the subject contains the value (case matters) |
subject_regex | the subject matches the Go regular expression; an invalid one matches nothing |
body_contains | the text or the HTML part contains the value (case matters) |
project | the message belongs to that project |
since, until | received at or after / at or before this time: RFC 3339 (2026-11-07T08:30:00Z), unix seconds, or unix milliseconds. A value that does not parse is ignored |
/messages also takes:
order:desc(newest first, the default) orasc.limitandoffsetfor pages. Nolimitreturns all matches.meta.totalcounts all matches before the page.
Waiting for an email
/messages/wait holds the request open until a matching message arrives. It also takes timeout: a Go duration such as 10s or 1m, default 30s, at most 60s.
A message that is already stored and matches comes back at once. So take a cursor before the action, and pass it as since. Otherwise an old email from an earlier test can match.
Example — a password reset test:
# 1. Remember "now"
CURSOR=$(curl -s http://127.0.0.1:8000/api/smtp/cursor | jq -r .cursor)
# 2. Your test asks the app to send the reset email to alice@example.com
# 3. Wait up to 20 seconds for it
UUID=$(curl -s -G http://127.0.0.1:8000/api/smtp/messages/wait \
--data-urlencode "since=$CURSOR" \
--data-urlencode "to=alice@example.com" \
--data-urlencode "subject_contains=Reset" \
--data-urlencode "timeout=20s" | jq -r .uuid)
# 4. Read the code from it
curl -s http://127.0.0.1:8000/api/smtp/message/$UUID/codes
# {"data":["482913"],"pattern":"\\b\\d{4,8}\\b"}Codes
/codes looks for a regular expression in the text part and in the HTML part (tags removed). The default pattern finds numbers of 4 to 8 digits. Each code is listed once. Pass your own pattern for other codes, for example pattern=[A-Z0-9]{6}. An invalid pattern gets 400.
Attachments
GET /api/smtp/attachments/{uuid} lists the attachments of a message: {"data": [{"uuid", "name", "path", "size", "mime"}]}. It needs the login like the routes above. The download (/api/smtp/attachments/{event uuid}/{attachment uuid}) and the preview (/api/smtp/attachments/{event uuid}/preview/{attachment uuid}) links stay open: they work only with both ids, which only the protected API gives out.