You are here

function email_confirmer_mail in Email confirmer 8

Implements hook_mail().

File

./email_confirmer.module, line 11
Email confirmation API and service.

Code

function email_confirmer_mail($key, &$message, $params) {
  switch ($key) {
    case 'confirmation_request':
      $context = $params['context'];

      // @todo recipient name?
      $message['to'] = $params['context']['email_confirmer_confirmation']
        ->getEmail();
      $message['subject'] = \Drupal::token()
        ->replace(\Drupal::config('email_confirmer.settings')
        ->get('confirmation_request.subject'), $context, [
        'sanitize' => FALSE,
      ]);
      $message['body'][] = \Drupal::token()
        ->replace(\Drupal::config('email_confirmer.settings')
        ->get('confirmation_request.body'), $context, [
        'sanitize' => FALSE,
      ]);
      break;
  }
}