Local wp-config.php or its analog should disable wp_mail()
Introduction
On occasion a local environment will send the “This site has encountered a fatal error” email notice to a client if they are listed as the admin.
Decision
Add the following function to the controlling wp-config.php, wp-config-local.php, or whatever the controlling file is in the local environment before pulling the database:
// Disable Outgoing WordPress Emails
function wp_mail() {
//
}
Context
- Clients have received this email in the past, generating confusion and churn explaining that it’s not their live site.
- The need to test email functionality in a local environment is almost non-existent.
- Most local setups do not enable mail by default but some, like sites with WP Mail SMTP or Local by Flywheel, do.
- If this step is not taken prior to completely activating the theme and database, there is the risk of a crash and subsequent client notification.
Consequences
- Local environments will not be able to use mail functionality.
Exceptions
- We need to test mail sending on a local.