示例#1
0
文件: Compose.php 项目: rosko/workapp
 function index()
 {
     $mailClass = new Model_Mail();
     $this->view->setTitle("Новое сообщение");
     $this->view->setLeftContent($this->view->render("left_attach", array()));
     $mailboxes = $mailClass->getUserOutMailboxes();
     if (isset($_POST["submit"])) {
         $helpers = new Helpers_Helpers();
         $smtp = $mailClass->getOutMailbox($_POST["mailbox"]);
         $fromName = $this->registry["ui"]["name"] . " " . $this->registry["ui"]["soname"];
         if (!($err = $helpers->phpmailer($_POST, $smtp, $fromName))) {
             $mailClass->saveOutMail($_POST, $smtp);
             $this->view->refresh(array("timer" => "1", "url" => "mail/"));
         } else {
             $this->view->mail_compose(array("err" => $err, "mailboxes" => $mailboxes, "post" => $_POST));
         }
     } else {
         $post = array();
         if (isset($_GET["action"]) and $_GET["action"] == "reply") {
             if (isset($_GET["mid"]) and is_numeric($_GET["mid"])) {
                 $mail = $mailClass->getMailFromId($_GET["mid"]);
                 $post["subject"] = "RE: " . $mail[0]["subject"];
                 $post["to"] = $mail[0]["email"];
                 $text = null;
                 $html = null;
                 for ($i = 0; $i < count($mail); $i++) {
                     if ($mail[0]["type"] == "text") {
                         $text = "<pre>> " . trim($mail[$i]["text"]) . "</pre>";
                     }
                     if ($mail[0]["type"] == "html") {
                         $html = "> " . trim($mail[$i]["text"]);
                     }
                 }
                 if ($html == null) {
                     $post["textfield"] = $text;
                 } else {
                     $post["textfield"] = $html;
                 }
                 $post["textfield"] = str_replace("\r\n", "\r\n> ", $post["textfield"]);
                 $post["textfield"] = $this->view->render("mail_reply", array("date" => $mail[0]["date"], "text" => $post["textfield"]));
                 $post["email"] = $mail[0]["to"];
             }
         } elseif (isset($_GET["obj"])) {
             $mail =& $_SESSION["mail"];
             $post["to"] = implode(", ", json_decode($mail["json"], true));
         }
         $this->view->mail_compose(array("mailboxes" => $mailboxes, "post" => $post));
     }
     $this->view->showPage();
 }
示例#2
0
文件: Mail.php 项目: rosko/workapp
 function sendMailComment($params)
 {
     $email = $params["email"];
     $cid = $params["cid"];
     $_POST["to"] = $email;
     $_POST["subject"] = "Комментарий";
     $_POST["textfield"] = $this->registry["tt"]->getCommentText($cid);
     $carr = $this->registry["tt"]->getComment($cid);
     foreach ($carr as $part) {
         $_POST["attaches"][] = $this->registry["rootPublic"] . "system/settings/../../" . $part["filename"];
     }
     $mailClass = new Model_Mail();
     $helpers = new Helpers_Helpers();
     $mailboxes = $mailClass->getUserOutMailboxes();
     for ($i = 0; $i < count($mailboxes); $i++) {
         if ($mailboxes[$i]["default"]) {
             $def = $i;
         }
     }
     $smtp = $mailClass->getOutMailbox($mailboxes[$def]["id"]);
     $fromName = $this->registry["ui"]["name"] . " " . $this->registry["ui"]["soname"];
     if (!($err = $helpers->phpmailer($_POST, $smtp, $fromName))) {
         $mailClass->saveOutMail($_POST, $smtp);
         $this->registry["tt"]->addCommentSendmail($cid);
     }
 }