public function sendSelfMsg() { $message = new Message(); $message->setTo(\common_session_SessionManager::getSession()->getUser()); $message->setBody('<h1>Tao Dev Message send on the ' . \tao_helpers_Date::displayeDate(time()) . '</h1>'); $success = MessagingService::singleton()->send($message); return $this->returnJson(array('success' => $success, 'message' => __('Send a message'))); }
/** * Send email message with password recovery instructions. * * @author Aleh Hutnikau <*****@*****.**> * @param core_kernel_classes_Resource $user The user has requested password recovery. * @return boolean Whether message was sent. */ public function sendMail(\core_kernel_classes_Resource $user) { $messagingService = $this->getMessagingService(); if (!$messagingService->isAvailable()) { throw new PasswordRecoveryException('Messaging service is not available.'); } $generisUser = new \core_kernel_users_GenerisUser($user); $userNameProperty = new \core_kernel_classes_Property(PROPERTY_USER_FIRSTNAME); $messageData = array('user_name' => (string) $user->getOnePropertyValue($userNameProperty), 'link' => $this->getPasswordRecoveryLink($user)); $message = new Message(); $message->setTo($generisUser); $message->setBody($this->getMailContent($messageData)); $message->setTitle(__("Your TAO Password")); $result = $messagingService->send($message); return $result; }