Skip to content

Mailpit

Part of the Sidecar Services catalog.

What it does

Mailpit is a mail catcher. It accepts SMTP from WordPress and holds every message in a web inbox instead of delivering it, so outbound mail (password resets, form notifications, WooCommerce receipts) is captured locally and nothing is sent for real. Add it when you want to see and inspect the mail a project sends without risking delivery to actual recipients.

Mailpit and MailHog do the same job; Mailpit is the newer, actively maintained option.

How it works

The preset pins axllent/mailpit:latest. The web inbox runs on container port 8025 and SMTP is accepted on 1025. It runs with MP_SMTP_AUTH_ACCEPT_ANY=1 and MP_SMTP_AUTH_ALLOW_INSECURE=1 so WordPress can connect without configuring credentials or TLS. Caught mail is not persisted to a volume, so the inbox is cleared when the container is recreated.

Mailpit gets a browser UI on port 8025: the host port is auto-allocated from the 7000 to 7999 range and de-conflicted across all projects.

bash
wdg my-site service add mailpit
wdg my-site service list

Read the inbox URL from the service list output.

How it integrates with the local WordPress container

Adding the sidecar injects these env vars into the WordPress container:

VariableValue
WORDPRESS_SMTP_HOSTwdg-my-site-mailpit (the @HOST token resolved at add-time)
WORDPRESS_SMTP_PORT1025

The injected env points WordPress at the SMTP endpoint, not the inbox UI. WordPress reaches Mailpit over wdg-network at wdg-my-site-mailpit:1025, never the host port. The host port serves the browser inbox only.

These env vars are connectivity hints. The project still routes wp_mail() through SMTP. With an SMTP plugin (for example WP Mail SMTP), or a small mu-plugin on phpmailer_init, read the injected host and port and no authentication:

php
add_action( 'phpmailer_init', function ( $phpmailer ) {
	$phpmailer->isSMTP();
	$phpmailer->Host       = getenv( 'WORDPRESS_SMTP_HOST' ); // wdg-my-site-mailpit
	$phpmailer->Port       = (int) getenv( 'WORDPRESS_SMTP_PORT' ); // 1025
	$phpmailer->SMTPAuth   = false;
	$phpmailer->SMTPSecure = '';
} );

Adding the sidecar wires reachability only. The project still configures WordPress to send over SMTP.

Add and remove

bash
wdg my-site service add mailpit
wdg my-site service remove mailpit  # no data volume to keep; --purge is a no-op here