MailManager override "from" email I use MailManager to send emails to end users for notifications. I would like to override the email address shown to the end user, using a "fake" address shown and not the real mail account used to send the email. I use the following code, however, in my gmail receiving account I don't see the noreply@mymailserver.com but the real email account used.

$params['message'] = $message;
$params['subject'] = $title;
$key = 'send_email';
$langcode = \Drupal::currentUser()-&gt;getPreferredLangcode();
$send = true;
$result = $mailManager-&gt;mail($module, $key, $targetEmail, $langcode,
                    $params, 'noreply@mymailserver.com', $send);


Is there a way to define a custom address to be shown to the end user? Am I missing something?
You can use hook_mail_alter to customize the From:

MODULE_NAME_mail_alter($key, &amp;$message, $params) {

  switch ($key) {
    case 'my_email_key':
      $message['headers']['From'] = 'My Email Name &lt;my_email@address.com&gt;';
      break;
  }
}