Php、IMAP如何注销?
在前面的问题中没有找到任何解决方案。 我已经开发了一个简单的imap访问我的服务器,它运行良好,但我有一个大问题 由于打开imap会话,服务器运行缓慢,正在停机 如何关闭/注销?在PHPIMAP文档中,我没有找到解决方案,我使用Php、IMAP如何注销?,php,Php,在前面的问题中没有找到任何解决方案。 我已经开发了一个简单的imap访问我的服务器,它运行良好,但我有一个大问题 由于打开imap会话,服务器运行缓慢,正在停机 如何关闭/注销?在PHPIMAP文档中,我没有找到解决方案,我使用 function correio ($caixa) { if($caixa ==="Inbox") { if($_REQUEST['user'] == "Gmail") { $box = imap_open(servidor."INBOX", u
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." 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."' /> ".$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));
函数对应($caixa){
如果($caixa==“收件箱”){
如果($_请求['user']==“Gmail”){
$box=imap_打开(servidor.“收件箱”,用户,通过)或死亡(imap_上次错误());
$informacoes=imap_状态($box,servidor.$caixa,sau ALL);
}否则{
$box=imap_打开(服务商、用户、通行证)或死亡(imap_上次错误());
$informacoes=imap_状态($box,servidor.“.”$caixa,sau ALL);
}
}否则{
如果($_请求['user']==“Gmail”){
$box=imap_open(servidor.“[Gmail]/”$caixa,user,pass)或die(imap_last_error());
$informacoes=imap_状态($box,servidor.“[Gmail]/”$caixa,sau ALL);
}否则{
$box=imap_打开(servidor.“.”$caixa,用户,通过)或死亡(imap_最后一次错误();
$informacoes=imap_状态($box,servidor.“.”$caixa,sau ALL);
}
}
若有($box){
$n=imap_复选框($box);
$conteudos=imap\u fetch\u overview($box,“1:{$n->Nmsgs}”,0);
$msgs.=”;
$msgs.=''.$caixa.''总计:“.$informacoes->messages.”,备忘录:“.$informacoes->recent.”,Não lidas:“.$informacoes->unseen.”;
$msgs.=”;
如果($conteudos){
foreach($conteudos作为$mensage){
$de=imap\U mime\U头\U解码($mensagem->from);
$msgs.=''.$de[0]->文本
$(“输入:复选框”)。单击(函数(事件){
event.stopPropagation();
});
";
$subject=imap\u mime\u header\u decode($mensage->subject);
对于($i=0;$itext;
}
$msgs.=““$assto.”
$('#msg'.$mensage->uid.')。单击(函数(){
版本管理(“$caixa.”、“$mensagem->uid.”);
});
”;
}
}否则{
$msgs.=“Não hámensagens novas.”;
}
$msgs.=”;
$msgs.=”;
返回$msgs;
imap_关闭($box);
}否则{
die(“Ligação recusada:.imap_last_error());
imap_关闭($box);
}
}
如果($inbox=&correio(“inbox”)){
$f=$inbox;
如果($spam=&correio(“spam”)){
$f.=$spam;
}
}
//回声“f=”.$f.“
”;
$str=”“;
$str.=$f;
$str=”;
$str.=”
";
echo$header.“| | |”。$str;
imap_关闭($box);
var_转储(imap_关闭($box));
如果连接关闭,您显然会注销。关闭可能会失败,imap\u close($box)
返回什么?imap\u close()的返回值是多少?它可以是真的或假的,但不能保证它总是关闭流
您可以尝试运行一个简单的测试设置:imap\u open()
,然后执行一个简单的命令,例如imap\u ping()
,然后立即执行imap\u close()
。这是按预期关闭连接还是保持打开状态
另外,请确保在首次关闭多个imap\u open()
s之前不要调用它们。请使用imap\u reopen()
、在imap\u open()
之前调用imap\u close()
或使用不同的变量存储连接标识符(但请确保同时使用imap\u close()
).imap\u close()
的返回值是多少?它可以是True
或False
,但不能保证它总是关闭流。还可以尝试运行一个简单的测试设置:imap\u open()
,然后执行一个简单的命令,例如imap\u ping()
,然后立即执行imap\u close()
。这是按预期关闭连接还是保持打开状态?if($box){if(imap_close($box)){include(“imap_app.php”);}否则{echo“没有关闭”}}我没有收到回音,但我被重定向到我的imap.php,所以我相信它正在关闭连接。你可以只使用var_dump(imap_close($box));
:-。。。不管怎样,您的脚本可能多次调用了imap\u open()
?