function send() { //print_r($this->_templete_params); try { $html = $this->getBodyContent(); $mail = new Zend_Mail('utf-8'); $mail->clearDefaultFrom(); $mail->setBodyHtml($html); $mail->addHeader('mailedby', WEB_HOST); // $mail->addHeader('X-MailGenerator', 'MyCoolApplication'); $mail->setFrom(App_Env::getSystemEmail(), App_Env::getSystemEmailFrom()); $this->setSender(App_Env::getSystemEmail()); foreach ($this->_to as $email) { $mail->addTo($email); } $this->addBcc(App_Env::getBccEmail()); if (count($this->_bcc) > 0) { foreach ($this->_bcc as $email) { $mail->addBcc($email); } } if ($this->getTemplateId() == Sys_Model_Template::EMAIL_NEW_ISSUE) { $this->_subject = str_replace("[ISSUE_NUMBER]", $this->getParam("ISSUE_NUMBER"), $this->_subject); } elseif ($this->getTemplateId() == Sys_Model_Template::EMAIL_REPLY_ISSUE) { $this->_subject = str_replace("[ISSUE_NUMBER]", $this->getParam("ISSUE_NUMBER"), $this->_subject); } $subject = $this->_subject; $mail->setSubject($this->_subject); $log = App_Log::get()->maillog($this); // บวก link $id = $log->id; $skey = $log->skey; $sid = base64_encode("{$id}&{$skey}&" . join(",", $this->_to)); $onlineurl = WEB_DOMAIN . "/e?sid={$sid}"; $html = "If you are having trouble reading this email, <a href='{$onlineurl}'>read the online version </a>." . $html; $mail->setBodyHtml($html); $this->_mail = $mail; $mail->send(); // ส่ง notify admin if ($this->_sendNotify and in_array($this->getTemplateId(), array(Sys_Model_Template::EMAIL_NEW_ISSUE, Sys_Model_Template::EMAIL_REPLY_ISSUE, Sys_Model_Template::EMAIL_ACCOUNT_INFO, Sys_Model_Template::EMAIL_INVOICE, Sys_Model_Template::EMAIL_PURCHASE_ORDER))) { $notifier = new App_Mail_Notifier(); $notifier->setSubject($subject); $notifier->setMailURL($onlineurl); $notifier->setAdminURL($this->getAdminURL()); $notifier->send(); } // echo "notify"; // exit(); } catch (Exception $e) { // $this->view->stat = 'error'; // $this->view->msg = $e->getMessage (); echo "error"; echo $e->getMessage(); // throw new Exception($e->getMessage()); } }