2013-08-26 156 views
1

我設法使用IMAP php庫顯示我的電子郵件,而不使用任何額外的框架。我得到的唯一問題是我無法獲取嵌入圖像。我可以看到我的imap_fetchstrucure電子郵件的結構,我的形象是從imap獲取嵌入式圖像php

[1] => stdClass Object ( [type] => 5 [encoding] => 3 [ifsubtype] => 1 [subtype] => JPEG [ifdescription] => 0 [ifid] => 1 [id] => <[email protected]> [bytes] => 2668 [ifdisposition] => 0 [ifdparameters] => 0 [ifparameters] => 1 [parameters] => Array ( [0] => stdClass Object ( [attribute] => name [value] => image002.jpg ) )

[email protected]地方,我怎麼能得到/顯示來自Gmail的這個形象?有沒有任何標準的URL來獲取圖片www.gmail.com/image002.jpg?

回答

0

搜索和研究之後,找到了解決辦法,我不會詳細獲取如何閱讀身體,但在這個例子中,我有4電子郵件和第三部分.jpg格式圖像嵌入:

<?php 
    $mbox = imap_open($hostname,$username,$password) 
      or die('Cannot connect to Gmail: ' .  imap_last_error()); 
    $message=imap_fetchbody($mbox, 4,3); 
    $decoded_data = base64_decode($message); 
    file_put_contents('image002.jpg',$decoded_data); 
?> 
    <img src="image002.jpg"> 
<?php 

你必須先保存它,然後才能顯示它。找不到直接顯示的方法。