WooCommerce Disable Emails Generator

Turn off specific WooCommerce emails in code, or stop all mail on a staging site, without touching the settings a client can change back.

Live output

Enable JavaScript to customise; default output below.

Mode

Staging mode stops every email the whole site sends, not just WooCommerce's, which is what you want on a copy of a live store.

Emails to turn off

Turning off customer_reset_password locks people out of their own accounts. It is listed because sometimes that is deliberate.

How

Filtering enabled leaves the email in the settings screen, greyed by your code. Removing the class takes it out entirely.

Live preview disable-emails.php
<?php
/**
 * WooCommerce emails, turned off.
 */

add_filter( 'woocommerce_email_enabled_cancelled_order', '__return_false' );
add_filter( 'woocommerce_email_enabled_customer_note', '__return_false' );

Output is valid and updates as you type.

Turn off the WooCommerce emails you do not want, or stop a staging copy emailing real customers, without relying on a settings checkbox anyone can tick back on.

How to use

  1. For a live store, turn off specific emails. Filtering enabled is the light touch; removing the class takes the email out of the settings screen entirely.
  2. For a copy of a live store, use staging mode. It blocks every email the site sends, not only WooCommerce’s, which is what matters when the copy has real orders in it.
  3. Guard staging mode with a constant defined only on the copy. That constant is the entire safety mechanism, so it belongs in wp-config.php, never in the database.
  4. Leave the admin exception on if you still want to receive test mail on staging.
  5. Keep the logging on while you are working. It proves an email would have gone, which is hard to demonstrate otherwise.

Example

Staging mode, the version that matters:

function acme_block_mail( $args ) {
	if ( ! defined( 'ACME_STAGING' ) || ! ACME_STAGING ) {
		return $args;
	}

	// No recipients means wp_mail() returns early without sending.
	$args['to'] = array();

	return $args;
}
add_filter( 'wp_mail', 'acme_block_mail' );

Emptying the recipient list is more reliable than trying to intercept every sender: anything that goes through wp_mail() is covered, including plugins you have not thought about.

Pitfalls

  • A staging copy made from a live database has real customer addresses in it. Restocking, bulk status changes and test refunds all send mail. This is the single most damaging WooCommerce mistake there is.
  • Turning off customer_reset_password means customers cannot recover their accounts, and the failure is silent from their side.
  • woocommerce_email_enabled_<id> leaves the email visible in the settings screen with its checkbox on, which confuses whoever looks after the store next.
  • Removing the class removes the settings too, including any subject or template overrides stored against it.
  • Blocking wp_mail() does not stop a plugin that talks to an SMTP API directly. SendGrid, Postmark and Mailgun plugins usually route through wp_mail(), but transactional integrations sometimes do not.
  • Some hosts and SMTP plugins short circuit wp_mail() themselves, at a priority that can run before your filter.
  • Order emails are sent during checkout. A fatal in this filter takes the order confirmation down with it.
  • The admin exception matches the admin_email option exactly. A staging copy usually still has the live address in it.

Compatibility

woocommerce_email_classes and woocommerce_email_enabled_<id> have been stable since WooCommerce 2.x and still apply in WooCommerce 8 and 9. The wp_mail filter, which receives and can rewrite the whole argument array, needs WordPress 5.5 or later; before that only wp_mail_from and friends existed. The generated code targets PHP 7.0 and up, and the tool runs entirely in your browser.

Frequently asked questions

How do I stop a staging site emailing customers?
Define the constant on the copy and use staging mode. Do it before the first import, not after.
Filter enabled or remove the class?
Filter for something temporary or conditional. Remove the class when the email should not exist for this store at all.
Does this block WordPress’s own emails?
Only in staging mode. The other modes touch WooCommerce emails only.
Will my SMTP plugin still send?
If it routes through wp_mail(), no. A direct API integration may bypass the filter entirely, so test before trusting it.
How do I test that mail is blocked?
Turn the logging on and trigger an order status change. The blocked recipient and subject appear in the PHP error log.

From the people who built this tool

WP Adminify

The WordPress admin, rebuilt: a dashboard worth looking at, menu and column control, a real file manager and the login page your client sees.

See WP Adminify Free version on WordPress.org

Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.