diff --git a/helfi_api_base.module b/helfi_api_base.module index 943fbcbd..b14d5494 100644 --- a/helfi_api_base.module +++ b/helfi_api_base.module @@ -50,3 +50,18 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array { $suggestions[] = 'debug_item__' . strtr($variables['id'], '.', '_'); return $suggestions; } + +/** + * Implements hook_mail_alter(). + */ +function helfi_api_base_mail_alter(&$message) : void { + // Prevent sending email if current site/environment is known to the resolver. + // Only helfi-drupal sites are affected by this change. + try { + \Drupal::service('helfi_api_base.environment_resolver') + ->getActiveEnvironment(); + $message['send'] = FALSE; + } + catch (\InvalidArgumentException) { + } +}