WordPress

Send wp_mail() — and every plugin that uses it — to a sandbox instead of the site's host.

Before you start

  • The WP Mail SMTP plugin (or any SMTP plugin)

1Configure the plugin

Either fill in the plugin's settings screen, or put the values in wp-config.php where they survive a database export:

wp-config.php
// wp-config.php — above "That's all, stop editing!"
define( 'WPMS_ON', true );
define( 'WPMS_MAILER', 'smtp' );
define( 'WPMS_SMTP_HOST', 'smtp.mailclutch.com' );
define( 'WPMS_SMTP_PORT', 587 );
define( 'WPMS_SSL', 'tls' );
define( 'WPMS_SMTP_AUTH', true );
define( 'WPMS_SMTP_USER', 'mc_0000000000000000' );
define( 'WPMS_SMTP_PASS', 'pw_0000000000000000' );

2Send a test message

WP Mail SMTP has an Email Test tab under its settings. Or from WP-CLI:

wp eval "wp_mail( 'anyone@example.com', 'Sandbox check', 'Hello from WordPress.' );"

Watch it land

Open the sandbox and the message is there — rendered HTML, plain text, raw source, attachments, and the SPF, DKIM and DMARC verdicts. It updates live, so you can leave it open next to your terminal.

Nothing is ever delivered onward, whatever address you send to; claim the inbox with an account and it stays.

Awaiting your email

Send from any address; it stops here rather than going onward. The inbox keeps what it catches for 24 hours.

What usually goes wrong

  • A staging copy of a live site

    Point the clone here and account emails, WooCommerce receipts and form notifications stay inside the sandbox instead of reaching real customers.

  • The From address

    Leave the plugin's From address on a domain you control. The sandbox accepts anything, but a mismatched From is what breaks the same test on a real provider later.

Official documentationWP Mail SMTP — documentation (opens in a new tab)