function messaging_privatemsg_send_msg in Messaging 6.2
Same name and namespace in other branches
- 6.4 messaging_privatemsg/messaging_privatemsg.module \messaging_privatemsg_send_msg()
- 6 messaging_privatemsg/messaging_privatemsg.module \messaging_privatemsg_send_msg()
- 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);
}
// this could be broken by minor changes to privatemsg_new_thread, which has an API different from its implementation at present
$ret = privatemsg_new_thread($recipients, $message->subject, $message->body, array(
'author' => $sender,
));
return $ret['success'];
}