Disable Emails 1.5.0 and 1.6.0

Disable Emails v1.6.0 has just been released. This release requires minimum PHP 5.6 (recommend 7.3 or greater); supports running as a must-use plugin; adds a WordPress admin indicator when active; fixes a couple of bugs.

Firstly, apologies for not getting out a release note for v1.5.0. It was on a Trello card, but things got a bit hectic so the blog post and tweet were bumped to the next version. This post includes notes for releases 1.5.0 and 1.6.0.

Minimum PHP version is 5.6

I’ve bumped the minimum supported version of PHP to version 5.6 (while recommending 7.3 or greater). If you still need to run PHP version 5.6, you have my commiserations, but I urge you to overcome any obstacles to upgrading PHP to 7.3 or greater. Truly, nobody should be running PHP 7.2 or earlier by now.

Must Use plugin

Version 1.5.0 added support for running the plugin as a Must Use plugin (mu-plugin). This brings a couple of benefits.

Firstly, if you’re working with a development or staging site and your duplication process doesn’t preserve the active plugins, enabling the Must Use plugin means that Disable Emails will always run regardless of whether it’s been activated. And for what it’s worth, if this is you, I recommend using a duplication process that does preserve the active plugins, e.g. WP Migrate DB Pro.

Secondly, regular plugins are loaded in alphabetical order, so a plugin called “AA Aardvark Awesome Email Commander” could slip in before Disable Emails and prevent it from disabling emails. Enabling the Must Use plugin prevents that from happening.

NB: if you are using this plugin on a multisite installation, please realise that Must Use plugins run on all sites in the multisite. Even with separate networks in the multisite, a Must Use plugin runs on all sites on all networks. This might be what you want to happen. Or it might not!

Trying to get property ‘ErrorInfo’ of non-objects

I noticed that a recent version of Gravity Forms started logging notices in the debug log when Disable Emails was active. This is fixed in v1.5.0 and should fix similar problems with other plugins that look for the real WordPress mail object.

Undefined index when emails sent during wp-cli

Running a WP-CLI command without setting the hostname via --url was logging notices when emails were sent. This was because the standard $_SERVER['SERVER_NAME'] PHP environment variable is not defined in WP-CLI without a URL being set. With v1.6.0, a bogus domain name is used instead of the missing server name.

You can update to the latest version from your WordPress plugin admin page. Here’s the full changelog for Disable Emails.