Using Test Mail Collector to avoid sending emails to users during testing This page offers some documentation on how to avoid sending emails to actual users during testing or in test environments:

https://www.drupal.org/docs/develop/local-server-setup/managing-mail-handling-for-development-or-testing

The simplest way appears to be modifying your settings.local.php:

$config['system.mail']['interface']['default'] = 'test_mail_collector';


If you use drush, you can then check the emails sent by running:
drush sget system.test_mail_collector

However after adding that line to my settings.local.php, I still received the actual emails. They were not "collected".

In looking at the source code in Drupal\Core\Mail\Plugin\Mail\TestMailCollector.php line 24

 $captured_emails = \Drupal::state()-&gt;get('system.test_mail_collector') ?: [];


It seems to me that the correct syntax for setting the test mail collector would be

$config['system.test_mail_collector'] = TRUE;


But that didn't work either.

I haven't been able to find documentation that helps me reverse-engineer the setting based on the retrievable of the state variable.
After my attempt to use Devel module for  DevelMailLog also failed using the configuration setting

$config['system.mail']['interface']['default'] = 'devel_mail_log';


I concluded there must be something in my environment that is blocking these features.

After uninstalling the module "MailSystem", then either of the two approaches worked as intended while mail was still received when the configuration setting was omitted.