使用imap php从gmail获取嵌入图像
我已经设法使用IMAP php库显示我的电子邮件,而不使用任何额外的框架。唯一的问题是我不能得到嵌入的图像。我可以通过imap_fetchstrucure看到我的电子邮件的结构,我的图像在其中的某个地方使用imap php从gmail获取嵌入图像,php,image,gmail,imap,Php,Image,Gmail,Imap,我已经设法使用IMAP php库显示我的电子邮件,而不使用任何额外的框架。唯一的问题是我不能得到嵌入的图像。我可以通过imap_fetchstrucure看到我的电子邮件的结构,我的图像在其中的某个地方 [1]=>stdClass对象 ( [类型]=>5 [编码]=>3 [ifsubtype]=>1 [子类型]=>JPEG [ifdescription]=>0 [ifid]=>1 [id]=> [字节]=>2668 [ifdisposition]=>0 [ifdparameters]=>0 [i
[1]=>stdClass对象
(
[类型]=>5
[编码]=>3
[ifsubtype]=>1
[子类型]=>JPEG
[ifdescription]=>0
[ifid]=>1
[id]=>
[字节]=>2668
[ifdisposition]=>0
[ifdparameters]=>0
[ifparameters]=>1
[参数]=>阵列
(
[0]=>stdClass对象
(
[属性]=>名称
[值]=>image002.jpg
))
图002。jpg@01CE9203.CFB44C60,如何从Gmail获取/显示此图像?是否有标准URL获取图像www.Gmail.com/image002.jpg?在搜索和研究后,找到了解决方案,我不会详细了解如何读取正文,但在本例中,我在第4封电子邮件和第3部分a.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