2014-02-18 4 views
0

PHP IMAP으로 이메일 메시지를 구문 분석하는 데 문제가 있습니다. 문제는 pkcs # 7 서명으로 메시지에 서명했습니다. 메일에는 일부 텍스트와 첨부 파일이 포함되어 있습니다. 첫 번째 파일은 smime.p7s이고 두 번째 파일은 message.htm입니다.이 파일은 html 첨부 파일입니다. 구문 분석하고 싶습니다.PHP IMAP 첨부 서명 받기

솔직히이 파일의 내용에 어떻게 접근 할 수 있는지 잘 모릅니다.

$hostname = '{host}INBOX'; 
    $username = 'name'; 
    $password = 'pass'; 
    /* try to connect */ 
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); 
    /* grab emails */ 
    $emails = imap_search($inbox,'UNSEEN'); 
    $msg = Array(); 
    if($emails) { 
     /* begin output var */ 
     $output = ''; 

     /* put the newest emails on top */ 
     rsort($emails); 
     /* for every email... */ 
     foreach($emails as $email_number) { 
      $overview = imap_fetch_overview($inbox,$email_number,0); 
      $message = imap_fetchbody($inbox,$email_number,2); 
      $structure = imap_fetchstructure ($inbox,$email_number,FT_UID); 
      echo "<pre>"; 
      var_dump($structure); 
      echo "</pre>"; 
      break; 
     } 
    } 

나는 전체 구조를 얻을 나는이 부분을 찾을 수 있습니다

 object(stdClass)#16 (14) { 
      ["type"]=> 
      int(0) 
      ["encoding"]=> 
      int(4) 
      ["ifsubtype"]=> 
      int(1) 
      ["subtype"]=> 
      string(4) "HTML" 
      ["ifdescription"]=> 
      int(0) 
      ["ifid"]=> 
      int(0) 
      ["lines"]=> 
      int(123) 
      ["bytes"]=> 
      int(4473) 
      ["ifdisposition"]=> 
      int(1) 
      ["disposition"]=> 
      string(10) "attachment" 
      ["ifdparameters"]=> 
      int(1) 
      ["dparameters"]=> 
      array(1) { 
      [0]=> 
      object(stdClass)#17 (2) { 
       ["attribute"]=> 
       string(8) "filename" 
       ["value"]=> 
       string(37) "message.htm" 
      } 
      } 
      ["ifparameters"]=> 
      int(1) 
      ["parameters"]=> 
      array(2) { 
      [0]=> 
      object(stdClass)#18 (2) { 
       ["attribute"]=> 
       string(4) "name" 
       ["value"]=> 
       string(37) "message.htm" 
      } 
      [1]=> 
      object(stdClass)#19 (2) { 
       ["attribute"]=> 
       string(7) "charset" 
       ["value"]=> 
       string(8) "us-ascii" 
      } 
      } 
     } 

는 아무도 내가 message.htm의 내용에 액세스 할 수있는 방법을 나에게 힌트를 줄 수 있습니까?

+0

당신이''위해서 var_dump ($ 구조)'후'위해서 var_dump ($ 메시지)를 시도? – willoller

+0

예 이것을 디코딩 한 후 일부 base64 인코딩 된 문자열을 얻었습니다. VeriSign으로 인코딩 된 임의의 기호를 얻었습니다. 인증서 같음 – Mithrand1r

+0

'imap_body (...) '를'imap_body (...)'로 바꾸어보십시오. – willoller

답변