You are here

function pm_email_notify_mail in Privatemsg 7

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.2 pm_email_notify/pm_email_notify.module \pm_email_notify_mail()

Implements hook_mail().

File

pm_email_notify/pm_email_notify.module, line 61
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(variable_get('pm_email_notify_subject', 'New private message at [site:name].'), $data, $options));
      $message['body'][] = trim(token_replace(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $data, $options));
      break;
  }
}