/** * Sends an email to this user. * @param string $subject The subject of the email. * @param string $message The content of the email being sent. * @return boolean */ public function sendEmail($subject, $message) { // Make sure we're not trying to send an email to a guest if ($this->isGuest()) { return; } // Make sure the email address is valid before we try sending anything if (!Utils::isValidEmail($this->getEmail())) { return false; } // Create the headers for the email $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/html; charset=UTF-8"; $headers[] = "From: " . APP_NAME . " <" . APP_EMAIL . ">"; $headers[] = "Reply-To: " . APP_NAME . " <" . APP_EMAIL . ">"; // Create the message to send using the email base tempalte $compiledMessage = View::compileView('email_base', array('subject' => $subject, 'message' => $message, 'app_name' => APP_NAME, 'user' => $this->row)); // Send the email return mail($this->getEmail(), $subject, $compiledMessage, implode("\r\n", $headers)); }