You are here

function commerce_mail in Commerce Core 8.2

Implements hook_mail().

Prepares emails sent by the MailHandler service.

3 string references to 'commerce_mail'
MailHandlerTest::testBasicEmail in tests/src/Kernel/MailHandlerTest.php
Tests sending a basic email, without any custom parameters.
MailHandlerThemeTest::testCustomTheme in tests/src/Kernel/MailHandlerThemeTest.php
Tests the email with custom theme.
MailHandlerThemeTest::testDefaultTheme in tests/src/Kernel/MailHandlerThemeTest.php
Tests the email without a custom theme.

File

./commerce.module, line 17
Defines common functionality for all Commerce modules.

Code

function commerce_mail($key, &$message, $params) {

  /** @var \Drupal\Core\Render\RendererInterface $renderer */
  $renderer = \Drupal::service('renderer');
  if (isset($params['headers'])) {
    $message['headers'] = array_merge($message['headers'], $params['headers']);
  }
  if (!empty($params['from'])) {
    $message['from'] = $params['from'];
  }
  $message['subject'] = $params['subject'];
  $message['body'][] = $renderer
    ->render($params['body']);
}