Skip to content

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.

A captured email with HTML preview

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 emailTab
text/watch-htmlApple Watch: shown at phone width, with a Source view
text/x-amp-htmlAMP: a static view, AMP scripts do not run; with a Source view
text/calendar, application/icsCalendar
message/delivery-statusDelivery status (a bounce report)
message/disposition-notificationRead receipt
text/rfc822-headersOriginal headers
text/enriched, text/richtext, text/markdownEnriched 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:CANCEL or STATUS: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 http or https.

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 text and html fields do not change: codes, links and body_contains read 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.1 with the Buggregator service name (e.g., buggregator).

Laravel ​

dotenv
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025

Spiral Framework ​

dotenv
MAILER_DSN=smtp://127.0.0.1:1025

Symfony ​

dotenv
MAILER_DSN=smtp://127.0.0.1:1025

Magento 2 ​

dotenv
CONFIG__DEFAULT__SYSTEM__SMTP__TRANSPORT="smtp"
CONFIG__DEFAULT__SYSTEM__SMTP__HOST="127.0.0.1"
CONFIG__DEFAULT__SYSTEM__SMTP__PORT="1025"

or via CLI:

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

WordPress ​

Save to the mu-plugins directory (e.g., smtp.php):

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:

dotenv
# Laravel
MAIL_USERNAME=shop
MAIL_PASSWORD=any

# Symfony, Spiral
MAILER_DSN=smtp://shop:any@127.0.0.1:1025

A 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):

yaml
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:

bash
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
KeyEnvironment variableDefault
hostSMTP_RELAY_HOSTempty: the button is off
portSMTP_RELAY_PORT587 for starttls, 465 for tls, 25 for none
tlsSMTP_RELAY_TLSstarttls; or tls, none
username, passwordSMTP_RELAY_USERNAME, SMTP_RELAY_PASSWORDno login
password_fileSMTP_RELAY_PASSWORD_FILEread the password from a file (Docker or Kubernetes secret)
fromSMTP_RELAY_FROMthe sender address given to the server; empty: the login if it is an address, else the email's From
allowed_recipientsSMTP_RELAY_ALLOWED_RECIPIENTS (comma-separated)who may get mail, see below
insecure_skip_verifySMTP_RELAY_INSECURE_SKIP_VERIFYfalse; 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 localhost or 127.0.0.1. From another machine, from Docker, or through a proxy that adds X-Forwarded-For, X-Forwarded-Host, X-Real-IP or Forwarded, 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_recipients must be set, and each pattern must name a real domain. *, *@* or *@*.com would 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).

MethodPathAnswer
GET/api/smtp/cursor{"cursor": "2026-11-07T08:30:09.123456789Z"}: the server time now
GET/api/smtp/messagesmessages that match the filters: {"data": [event, …], "meta": {"total", "limit", "offset"}}
GET/api/smtp/messages/waitthe 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}/rawthe original message source (Content-Type: message/rfc822)
GET/api/smtp/message/{uuid}/linkslinks 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. size is in bytes before the 1 MB cut; truncated is true when 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"}]}. start and end are RFC 3339 when the zone is known (2026-12-01T09:00:00Z); a local time plus tz when it is not (2026-12-03T14:00:00, W. Europe Standard Time); a date when all_day is true.

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.

ParameterMatches when
to, from, ccany address or name in that field contains the value, ignoring case (to=alice finds Alice <alice@example.com>)
subjectthe subject is exactly the value
subject_containsthe subject contains the value (case matters)
subject_regexthe subject matches the Go regular expression; an invalid one matches nothing
body_containsthe text or the HTML part contains the value (case matters)
projectthe message belongs to that project
since, untilreceived 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) or asc.
  • limit and offset for pages. No limit returns all matches. meta.total counts 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:

bash
# 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.