Prevent drupal from sending e-mails [drupal 8 or 9]

First of all, you can use hook_mail_alter. While I'm not a fan of using hooks, this works:

/**
* Implements hook_mail_alter
*/
function MYMODULE_mail_alter(&$message) {
  // set 'To' field to nothing, so Drupal won’t have any address
  $message['to'] = ''; 
}

Or, just install this contrib module: Reroute Email

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!