some servers seem to sent their responses for the content not with the first EXT section, so we loop through the parsed response until we find some matching content; second attempt

This commit is contained in:
Klaus Leithoff 2012-08-14 08:11:24 +00:00
parent 18bdcacf0d
commit 96d5e48885
2 changed files with 27 additions and 13 deletions

View File

@ -560,7 +560,12 @@ class Net_IMAP extends Net_IMAPProtocol {
if(strtoupper($ret["RESPONSE"]["CODE"]) != "OK"){
return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]);
}
$ret=$ret["PARSED"][0]["EXT"]["BODY[TEXT]"]["CONTENT"];
$found = 0;
foreach($ret["PARSED"] as $key => $value)
{
if (isset($ret["PARSED"][$key]["EXT"]["BODY[TEXT]"]["CONTENT"])) {$found = $key; break;}
}
$ret=$ret["PARSED"][$found]["EXT"]["BODY[TEXT]"]["CONTENT"];
//$ret=$resp["PARSED"][0]["EXT"]["RFC822"]["CONTENT"];
return $ret;
}
@ -624,23 +629,29 @@ class Net_IMAP extends Net_IMAPProtocol {
} else {
$ret=$this->cmdFetch($msg_id,"BODYSTRUCTURE");
}
#_debug_array($ret);
#_debug_array($ret);
if (PEAR::isError($ret)) {
return $ret;
}
if(strtoupper($ret["RESPONSE"]["CODE"]) != "OK"){
return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]);
}
$ret2=$ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"][0];
// sometimes we get an [COMMAND] => OK with $ret["PARSED"][0] and no $ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"]
if (is_array($ret) && empty($ret2) && isset($ret["PARSED"])) {
foreach($ret["PARSED"] as $substruct) {
if ($substruct["COMMAND"] == "FETCH") {
$ret2=$substruct["EXT"]["BODYSTRUCTURE"][0];
break;
}
}
}
$found = 0;
foreach($ret["PARSED"] as $key => $value)
{
if (isset($ret["PARSED"][$key]["EXT"]["BODYSTRUCTURE"][0])) {$found = $key; break;}
}
$ret2=$ret["PARSED"][$found]["EXT"]["BODYSTRUCTURE"][0];
// sometimes we get an [COMMAND] => OK with $ret["PARSED"][0] and no $ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"]
// should not happen anymore
if (is_array($ret) && empty($ret2) && isset($ret["PARSED"])) {
foreach($ret["PARSED"] as $substruct) {
if ($substruct["COMMAND"] == "FETCH") {
$ret2=$substruct["EXT"]["BODYSTRUCTURE"][0];
break;
}
}
}
$structure = array();
$mimeParts = array();

View File

@ -1144,8 +1144,11 @@ class felamimail_bo
{
static $structure;
$_folder = $this->sessionData['mailbox'];
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
if (is_null($structure)) $structure = egw_cache::getCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($structure[$this->icServer->ImapServerId][$_folder][$_uid]))
if (isset($structure[$this->icServer->ImapServerId]) && !empty($structure[$this->icServer->ImapServerId]) &&
isset($structure[$this->icServer->ImapServerId][$_folder]) && !empty($structure[$this->icServer->ImapServerId][$_folder]) &&
isset($structure[$this->icServer->ImapServerId][$_folder][$_uid]) && !empty($structure[$this->icServer->ImapServerId][$_folder][$_uid]))
{
if ($_ignoreCache===false)
{