2011-04-01 9 views
0

이전 질문에서 해결책을 찾지 못했습니다. 저는 서버에 대한 간단한 imap 액세스를 개발했습니다. 잘 작동하지만 큰 문제가 있습니다.PHP, IMAP 로그 아웃하는 방법?

열려있는 imap 세션으로 인해 서버가 느리게 실행 중입니다.

어떻게 닫고 로그 아웃합니까? 나는 해결책을 찾을하지 않는 PHP는 IMAP 문서에서, 나는 연결이 닫혀있는 경우, 당신은 분명 로그 아웃이

function correio ($caixa) { 
if($caixa ==="Inbox") { 
    if($_REQUEST['user'] == "Gmail") { 
     $box = imap_open(servidor."INBOX", user, pass) or die (imap_last_error()); 
     $informacoes = imap_status($box, servidor.$caixa, SA_ALL); 
    } else { 
     $box = imap_open(servidor, user, pass) or die (imap_last_error()); 
     $informacoes = imap_status($box, servidor.".".$caixa, SA_ALL); 
    } 
} else { 
    if($_REQUEST['user'] == "Gmail") { 
     $box = imap_open(servidor."[Gmail]/".$caixa, user, pass) or die (imap_last_error()); 
     $informacoes = imap_status($box, servidor."[Gmail]/".$caixa, SA_ALL); 
    } else { 
     $box = imap_open(servidor.".".$caixa, user, pass) or die (imap_last_error()); 
     $informacoes = imap_status($box, servidor.".".$caixa, SA_ALL); 
    } 
} 
if($box) { 
    $n = imap_check($box); 
    $conteudos = imap_fetch_overview($box,"1:{$n->Nmsgs}", 0); 
    $msgs .= "<div id='div_".$caixa."' class='menu'>"; 
     $msgs .= "<h3 id='".$caixa."' class='".$caixa."'>".$caixa."&nbsp;&nbsp;&nbsp;&nbsp;Total: ".$informacoes->messages.", Últimas: ".$informacoes->recent.", Não lidas: ".$informacoes->unseen."</h3>"; 
     $msgs .= "<div class='mensagens'>"; 
      if($conteudos) { 
       foreach($conteudos as $mensagem) { 
        $de = imap_mime_header_decode($mensagem->from); 
        $msgs .= "<h1 class='".$caixa."'><input type='checkbox' id='".$mensagem->uid."' class='in_".$caixa."' />&nbsp;&nbsp;".$de[0]->text." 
        <script type='text/javascript'> 
         $('input:checkbox').click(function(event) { 
          event.stopPropagation(); 
         }); 
        </script> 
        </h1>"; 
        $subject = imap_mime_header_decode($mensagem->subject); 
        for ($i=0; $i<count($subject); $i++) { 
         $assunto = $subject[$i]->text; 
        } 
        $msgs .= "<p id='msg_".$mensagem->uid."'>".$assunto." 
           <script type='text/javascript'> 
            $('#msg_".$mensagem->uid."').click(function() { 
             ver_mensagem('".$caixa."', '".$mensagem->uid."'); 
            }); 
          </script> 
          </p>"; 
       } 
      } else { 
       $msgs .= "<h1 class='".$caixa."'>Não há mensagens novas.</h1>"; 
      } 
     $msgs .= "</div>"; 
    $msgs .= "</div>"; 
    return $msgs; 
    imap_close($box); 
} else { 
    die("Ligação recusada: " . imap_last_error()); 
    imap_close($box); 
} 
} 

if($inbox =& correio("Inbox")) { 
    $f = $inbox; 
    if($spam =& correio("Spam")) { 
     $f .= $spam; 
    } 
} 
//echo "f = ".$f."<br />"; 
$str = "<div id='wrapper'><div id='mobimail' style='display:none'>"; 
$str .= $f; 
$str .= "</div></div>"; 
$str .= "<div id='footer' class='footer' align='center'> 
<div class='todos' align='center'></div> 
<div class='apagar' align='center'></div> 
<div class='mover' align='center'></div> 
<div class='reload' align='center'></div> 
<div class='sair' align='center'></div> 
</div>"; 
echo $header."|||".$str; 
imap_close($box); 
var_dump(imap_close($box)); 
+0

'imap_close()'의 반환 값은 무엇입니까? 'True' 또는'False' 일 수 있습니다. 항상 스트림을 닫을 것이라고 보장 할 수 없습니다. – Carpetsmoker

+0

또한 간단한 테스트 셋업'imap_open()'과'imap_ping()'과 같은 간단한 명령을 실행 한 다음 즉시'imap_close()'를 실행 해보십시오. 이 연결이 예상대로 닫히지 않습니까? – Carpetsmoker

+0

if ($ box) { \t if (imap_close ($ box)) { \t \t ("imap_app.php"); \t} else { \t \t echo "닫지 않음"; \t} } – Pluda

답변

0

를 사용합니다. 닫는 것이 아마도 실패합니다. imap_close($box)은 무엇을 반환합니까?

0

imap_close()의 반환 값은 무엇입니까? True 또는 False 일 수 있습니다. 항상 스트림을 닫을 것이라고 보장 할 수 없습니다.

간단한 테스트 설정 (imap_open())을 실행하고 imap_ping()과 같은 간단한 명령을 실행 한 다음 바로 imap_close()과 같은 간단한 명령을 실행 해 볼 수 있습니다. 이 연결이 예상대로 닫히지 않습니까?

또한 먼저 닫으려면 imap_open()을 여러 번 호출하지 마십시오. imap_reopen()을 사용하거나 을 imap_open() 앞에 두거나 다른 변수를 사용하여 연결 식별자를 저장하십시오 (단, imap_close() 두 가지 모두를 사용하십시오).

관련 문제