I need to stop sending my webform submission email programmatically and conditionally. By conditionally I mean I have two contact forms and two locales on my Drupal application. I have a custom configuration in the admin end based upon which I will be allowing/disallowing the webform submission emails only for the contact form and locale I choose at the backend configuration.
I have seen an answer at How to stop webform from sending an email that point me to do this in hook_webform_submission_insert but my preference is do do it via a handler. I'm not able to comment on that answer as i don't have enough stackoverflow reputation.
I know in Drupal 7 we were able to do it by simply setting the flag $message['send'] = false; Is there a way to in a similar way in Drupal 10? This might be simple but I could not find a way around this. Please help.