You are here

function pm_email_notify_send_mail in Privatemsg 6.2

Same name and namespace in other branches
  1. 7.2 pm_email_notify/pm_email_notify.module \pm_email_notify_send_mail()

Send a pm notification email to a recipient.

Parameters

$recipient: Recipient user object.

$message: Message object.

2 calls to pm_email_notify_send_mail()
pm_email_notify_privatemsg_message_insert in pm_email_notify/pm_email_notify.module
Implements hook_privatemsg_message_insert().
pm_email_notify_privatemsg_message_recipient_changed in pm_email_notify/pm_email_notify.module
Implements hook_privatemsg_message_recipient_changed().

File

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

Code

function pm_email_notify_send_mail($recipient, $message) {

  // Check if the recipient enabled email notifications.
  if (isset($recipient->uid) && !empty($recipient->mail) && _pm_email_notify_send_check($recipient->uid, $message)) {

    // Send them a new pm notification email if they did.
    $params['recipient'] = $recipient;
    $params['message'] = $message;
    if (_pm_email_notify_show_sender($message['author']->uid)) {

      // User author's email as a sender.
      $from = $message['author']->mail;
    }
    else {
      $from = variable_get('pm_email_notify_from', '');
    }
    drupal_mail('pm_email_notify', 'notice', $recipient->mail, user_preferred_language($recipient), $params, !empty($from) ? $from : NULL);
  }
}