Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Don’t send emails from staging copies

On staging, development and local copies of the site, WordPress doesn’t send any email, so customers never get a test order confirmation.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Email
  • Tested with WordPress 7.1
PHP
<?php

add_filter(
	'pre_wp_mail',
	static function ( $return ) {
		if ( 'production' !== wp_get_environment_type() ) {
			return true; // Pretend it was sent.
		}
		return $return;
	}
);

Good to know

Needs WP_ENVIRONMENT_TYPE set on the copy. Mail plugins that don’t use wp_mail() aren’t stopped.

In these packs

  • Email: Emails from your name and address, sent through SMTP, and fewer notification emails.
  • Developer tools: Maintenance mode, template names, page stats, environment labels and a WP-Cron viewer.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.