Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Mail/MailManager.php \Drupal\Core\Mail\MailManager::mail()
  2. 9 core/lib/Drupal/Core/Mail/MailManager.php \Drupal\Core\Mail\MailManager::mail()

File

core/lib/Drupal/Core/Mail/MailManager.php, line 174

Class

MailManager
Provides a Mail plugin manager.

Namespace

Drupal\Core\Mail

Code

public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {

  // Mailing can invoke rendering (e.g., generating URLs, replacing tokens),
  // but emails are not HTTP responses: they're not cached, they don't have
  // attachments. Therefore we perform mailing inside its own render context,
  // to ensure it doesn't leak into the render context for the HTTP response
  // to the current request.
  return $this->renderer
    ->executeInRenderContext(new RenderContext(), function () use ($module, $key, $to, $langcode, $params, $reply, $send) {
    return $this
      ->doMail($module, $key, $to, $langcode, $params, $reply, $send);
  });
}