$log_pop = new CSourcePOP(); $log_pop->name = "user-pop-" . $user->_id; $log_pop->loadMatchingObject(); if (!$log_pop) { CAppUI::stepAjax("Source POP indisponible", UI_MSG_ERROR); } if (!$mail_id) { CAppUI::stepAjax("CSourcePOP-error-mail_id", UI_MSG_ERROR); } //pop init $pop = new CPop($log_pop); $pop->open(); //mail $mail = new CUserMail(); $head = $pop->header($mail_id); $content = $pop->getFullBody($_mail, false, false, true); $hash = $mail_unseen->makeHash($head, $content); $mail->loadMatchingFromHash($hash); if ($mail->_id && !$mail->text_plain_id) { $mail->setHeaderFromSource($head); $mail->setContentFromSource($pop->getFullBody($_mail, false, false, true)); $mail->date_read = CMbDT::dateTime(); $mail->user_id = $user->_id; //text plain if ($mail->_text_plain) { $textP = new CContentAny(); $textP->content = $mail->_text_plain; if ($msg = $textP->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } $mail->text_plain_id = $textP->_id;
$mail->loadAttachments(); //client POP $clientPOP = new CSourcePOP(); $clientPOP->load($mail->account_id); $pop = new CPop($clientPOP); if (!$pop->open()) { return; } //overview $overview = $pop->header($mail->uid); $msgno = $overview->msgno; $infos = $pop->infos($msgno); //structure $structure = $pop->structure($mail->uid); //content $content = $pop->getFullBody($mail->uid); //attachments $attachments = array(); $_attachments = $pop->getListAttachments($mail->uid); foreach ($_attachments as $_attach) { $attachments[] = $_attach->getPlainFields(); } $pop->close(); $smarty = new CSmartyDP(); $smarty->assign("mail", $mail); $smarty->assign("overview", $overview); $smarty->assign("structure", $structure); $smarty->assign("mail_id", $mail_id); $smarty->assign("content", $content); $smarty->assign("attachments", $attachments); $smarty->assign("infos", $infos);