You are here

function pm_email_notify_mail in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 pm_email_notify/pm_email_notify.module \pm_email_notify_mail()
  2. 6 pm_email_notify/pm_email_notify.module \pm_email_notify_mail()
  3. 7 pm_email_notify/pm_email_notify.module \pm_email_notify_mail()

Implements hook_mail().

File

pm_email_notify/pm_email_notify.module, line 299
Notifies users about new Private Messages via Email.

Code

function pm_email_notify_mail($key, &$message, $params) {
  switch ($key) {
    case 'notice':
      $data = array(
        'privatemsg_message' => $params['message'],
        'privatemsg_recipient' => $params['recipient'],
      );
      $options = array(
        'language' => user_preferred_language($params['recipient']),
        // Don't sanitize output since this is used in an email, not a browser.
        'sanitize' => FALSE,
        // Custom token to avoid custom token handling.
        'privatemsg-display-invalid' => FALSE,
      );
      $message['subject'] = trim(token_replace(pm_email_notify_text('subject', $options['language']), $data, $options));
      $message['body'][] = trim(token_replace(pm_email_notify_text('body', $options['language']), $data, $options));
      break;
  }
}