I'm sending emails programatically from a custom module, the email sends correctly to the user, but it also sends the email to the site email. Is there anyway to stop this from happening? When I receive the email it contains a reply-to link of the site email.

$mailManager = \Drupal::service('plugin.manager.mail');
$module = 'my_module';
$key = 'email_key';
$to = $user->get('mail')->getValue()[0]["value"];
$params['message'] = "Some message";
$params['subject'] = "Some subject";
$langcode = $user->getPreferredLangcode();
$send = true;
$result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.