function MailManager::mail

Same name in other branches
  1. 9 core/lib/Drupal/Core/Mail/MailManager.php \Drupal\Core\Mail\MailManager::mail()
  2. 8.9.x core/lib/Drupal/Core/Mail/MailManager.php \Drupal\Core\Mail\MailManager::mail()
  3. 11.x 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);
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.