/** * This function sends an email out to the user referenced by the notification_user record, * and returns whether sending the email was successful or not. * @return bool */ public function send() { global $db, $AGENT_CONTACTS; require_once "Models/utility/TemplateMailer.class.php"; $query = "SELECT a.`proxy_id`, b.`firstname`, b.`lastname`, b.`email`, a.`content_type`, a.`record_id`, a.`record_proxy_id` FROM `notification_users` AS a\n\t\t\t\t\tJOIN `" . AUTH_DATABASE . "`.`user_data` AS b\n\t\t\t\t\tON a.`proxy_id` = b.`id`\n\t\t\t\t\tWHERE a.`nuser_id` = " . $db->qstr($this->nuser_id); $user = $db->GetRow($query); if ($user) { $template = new Template(); $template->loadString($this->notification_body); $mail = new TemplateMailer(new Zend_Mail()); $mail->addHeader("X-Section", APPLICATION_NAME . " Notifications System", true); $from = array("email" => $AGENT_CONTACTS["agent-notifications"]["email"], "firstname" => APPLICATION_NAME . " Notification System", "lastname" => ""); $to = array("email" => $user["email"], "firstname" => $user["firstname"], "lastname" => $user["lastname"]); try { $mail->send($template, $to, $from, DEFAULT_LANGUAGE); if ($this->setSentStatus(true)) { application_log("success", "A [" . $user["content_type"] . "] notification has been sent to a user [" . $user["proxy_id"] . "] successfully."); return true; } } catch (Zend_Mail_Transport_Exception $e) { system_log_data("error", "Unable to send [" . $user["content_type"] . "] notification to user [" . $user["proxy_id"] . "]. Template Mailer said: " . $e->getMessage()); } } return false; }