2013-04-27 67 views
2

我在imap_fetchstructure($ this-> stream,$ messageNumber)中有問題。 一些電子郵件使用完美,另一封電子郵件不起作用,問題是:零件對象在結構中缺失。imap_fetchstructure()不返回零件對象

正如我所說的一些Gmail帳戶的代碼工作完美,我必須使用不工作來獲取消息結構。但郵件信息,頭我沒有問題,問題是如果我打電話這個功能

$ msg = $ imap-> returnEmailMessageArr($ val ['msgno']);

//後,該功能被稱爲

私有函數returnMessageStructureObj($ messageNumber){

return imap_fetchstructure($this->stream,$messageNumber); 
} 

爲未取的部分對象,該對象的Gmail帳戶,該結構如下:

stdClass Object 
(
    [type] => 0 
    [encoding] => 4 
    [ifsubtype] => 1 
    [subtype] => HTML 
    [ifdescription] => 0 
    [ifid] => 0 
    [lines] => 166 
    [bytes] => 9904 
    [ifdisposition] => 0 
    [ifdparameters] => 0 
    [ifparameters] => 0 
    [parameters] => stdClass Object 
     (
     ) 

) 

請幫我找到這個問題非常感謝

+0

單部分消息不會有「部分」,是嗎? – tripleee 2013-04-27 06:45:22

回答

0

->type0的消息定義爲text,並且將不包含任何部分。

0

我有同樣的問題,我用下面的代碼解決了,我只需要在郵件 其中$ val是UID的獲取身體,或者您也可以使用message_no

$structure = imap_fetchstructure($connection,$val,FT_UID); 
if($structure->type!=0) 
{ 
$data = imap_fetchbody($connection,$val,1,FT_UID); 
    if ($structure->encoding==4) 
     $data = quoted_printable_decode($data); 
    elseif ($structure->encoding==3) 
     $data = base64_decode($data); 
    if (strtolower($structure->subtype)=='plain') 
     $plainmsg .= trim($data) ."\n\n"; 
    else 
    $htmlmsg .= $data ."<br><br>"; 
}