You are here

function messaging_privatemsg_send_msg in Messaging 6

Same name and namespace in other branches
  1. 6.4 messaging_privatemsg/messaging_privatemsg.module \messaging_privatemsg_send_msg()
  2. 6.2 messaging_privatemsg/messaging_privatemsg.module \messaging_privatemsg_send_msg()
  3. 6.3 messaging_privatemsg/messaging_privatemsg.module \messaging_privatemsg_send_msg()

Send mail message to user accounts

Privatemsg API documentation on http://drupal.org/node/369399

Parameters

$destination: User account or user id

1 string reference to 'messaging_privatemsg_send_msg'
messaging_privatemsg_messaging in messaging_privatemsg/messaging_privatemsg.module
Implementation of hook_messaging

File

messaging_privatemsg/messaging_privatemsg.module, line 38
Simple mail using Drupal API. Messaging method plug-in

Code

function messaging_privatemsg_send_msg($destination, $message) {

  // Prepare the privatemsg parameters
  $recipients = is_object($destination) ? array(
    $destination,
  ) : array(
    messaging_load_user($destination),
  );
  if (!empty($message->sender_account)) {
    $sender = $message->sender_account;
  }
  elseif (!empty($message->sender)) {
    $sender = messaging_load_user($message->sender);
  }
  return (bool) privatemsg_new_thread($message->subject, $message->body, $recipients, $sender);
}