You are here

function private_message_mail in Private Message 8

Implements hook_mail().

File

./private_message.module, line 463
Contains hooks for the private message module.

Code

function private_message_mail($key, &$message, $params) {
  if ($key == 'message_notification') {
    $token = \Drupal::token();
    $mail_config = \Drupal::config('private_message.mail');
    $message_subject = $mail_config
      ->get('message_notification.subject');
    $message_body = $mail_config
      ->get('message_notification.body');
    $data['user'] = $params['member'];
    $data['private_message'] = $params['private_message'];
    $data['private_message_thread'] = $params['private_message_thread'];
    $message['subject'] = $token
      ->replace($message_subject, $data);
    $body = $token
      ->replace($message_body, $data);
    $message['from'] = \Drupal::config('system.site')
      ->get('mail');
    $message['subject'] = SafeMarkup::checkPlain($message['subject']);
    $message['body'][] = MailFormatHelper::htmlToText(Xss::filter($body));
  }
}