How can I add an BCC or CC email with programmatically?
What you want to do is ensure you are defining a message type in your custom module, you can then target the message within a hook_mail_alter() to add the desired CC or BCC.
function MYMODULE_mail_alter(array &amp;$message) {
  $bccEmail = 'test@test.com';

  if ($message['xxx'] == 'xxx') {
    $existingBcc = isset($message['headers']['Bcc']) ? $message['headers']['Bcc'] : '';
    $message['headers']['Bcc'] = implode(' ', array_merge(
      explode(' ', $existingBcc), [$bccEmail])
    );
  }
}

https://git.drupalcode.org/project/bcc/-/blob/8.x-3.x/bcc.module has an example of adding a bcc.