*/ CCanDo::checkRead(); $user = CMediusers::get(); $mail_id = CValue::get("mail_id"); $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;
$firstCheck = $firstEmailDate; $firstCheck = CMbDT::dateTime("+1 DAY", $firstCheck); $month_number = CMbDT::format($firstCheck, "%m"); $month = reset(array_keys(CFTP::$month_to_number, $month_number)); $dateIMAP = CMbDT::format($firstCheck, "%d-{$month}-%Y"); } else { $lastEmailDate = CUserMail::getLastMailDate($_source->_id); $firstCheck = $lastEmailDate; $firstCheck = CMbDT::dateTime("-1 DAY", $firstCheck); $month_number = CMbDT::format($firstCheck, "%m"); $month = reset(array_keys(CFTP::$month_to_number, $month_number)); $dateIMAP = CMbDT::format($firstCheck, "%d-{$month}-%Y"); } //pop open account $pop = new CPop($_source); if (!$pop->open()) { CAppUI::stepAjax("Impossible de se connecter à la source (open) %s", UI_MSG_WARNING, $_source->_view); continue; } //If import mode (get before actual) if ($import) { $unseen = $pop->search('BEFORE "' . $dateIMAP . '"', true); } else { $unseen = $pop->search('SINCE "' . $dateIMAP . '"', true); } $results = count($unseen); $total = imap_num_msg($pop->_mailbox); //if get last email => check if uid server is > maxuidMb // @TODO : temporarly removed, we already get the more recent mail for filter /*if (!$import) { foreach ($unseen as $key => $_unseen) {
function isAuthentificate() { $pop = new CPop($this); if (!$pop->open()) { return false; } $pop->close(); return true; }
if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) { CAppUI::stepAjax("CExchangeSource-error-noSourceName", UI_MSG_ERROR); } if (null == ($type_action = CValue::get("type_action"))) { CAppUI::stepAjax("CExchangeSource-error-noTestDefined", UI_MSG_ERROR); } /** @var CSourcePOP $exchange_source */ $exchange_source = CExchangeSource::get($exchange_source_name, "pop", true, null, false); if (!$exchange_source->_id) { CAppUI::stepAjax("CExchangeSource-error-unsavedParameters", UI_MSG_ERROR); } $pop = new CPop($exchange_source); switch ($type_action) { case 'connexion': try { if ($pop->open()) { CAppUI::stepAjax("CSourcePOP-info-connection-established@%s:%s", UI_MSG_OK, $exchange_source->host, $exchange_source->port); } } catch (CMbException $e) { $e->stepAjax(UI_MSG_WARNING); } break; case 'listBox': try { if ($pop->open()) { $boxes = imap_list($pop->_mailbox, $pop->_server, "*"); CAppUI::stepAjax("OK, %d comptes", UI_MSG_OK, count($boxes)); foreach ($boxes as $_box) { echo $_box . '<br/>'; } }