PHP Imap Body编码

时间:2016-07-25 08:55:41

标签: php imap

我有一个问题。我通过“PHPMailer”类发送电子邮件。然后我用Outlook 2013回复了这封邮件。后记我试图通过PHP用“imap_fetchbody”阅读电子邮件。但我只得到

PGh0bWwgeG1sbnM6dj0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp2bWwiIHhtbG5zOm89InVy bjpzY2hlbWFzLW1pY3Jvc29mdC1jb206b2ZmaWNlOm9mZmljZSIgeG1sbnM6dz0idXJuOnNjaGVt YXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6d29yZCIgeG1sbnM6bT0iaHR0cDovL3NjaGVtYXMubWlj cm9zb2Z0LmNvbS9vZmZpY2UvMjAwNC8xMi9vbW1sIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv VFIvUkVDLWh0bWw0MCI+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIg Y29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxtZXRhIG5hbWU9IkdlbmVyYXRv ciIgY29udGVudD0iTWljcm9zb2Z0IFdvcmQgMTUgKGZpbHRlcmVkIG1lZGl1bSkiPg0KPCEtLVtp ZiAhbXNvXT48c3R5bGU+dlw6KiB7YmVoYXZpb3I6dXJsKCNkZWZhdWx0I1ZNTCk7fQ0Kb1w6KiB7 YmVoYXZpb3I6dXJsKCNkZWZhdWx0I1ZNTCk7fQ0Kd1w6KiB7YmVoYXZpb3I6dXJsKCNkZWZhdWx0 I1ZNTCk7fQ0KLnNoYXBlIHtiZWhhdmlvcjp1cmwoI2RlZmF1bHQjVk1MKTt9DQo8L3N0eWxlPjwh W2VuZGlmXS0tPjxzdHlsZT48IS0tD[...]

这样的东西 - 我在imap_fetchbody函数中尝试了很多解码选项,但我没有得到它 - 这是我的代码:

$server='{IPADDRESS:143/novalidate-cert}INBOX';
$adresse='cloud@MYDOMAIN';
$password='MYPASSWORD';
$mbox = imap_open($server, $adresse, $password, OP_READONLY, 1, array('DISABLE_AUTHENTICATOR' => 'PLAIN')) or die(var_dump(imap_errors()));

$no = 1;
$headers = imap_headers($mbox);
$text = imap_fetchbody($mbox, $no, 1);
 
for($i = 0; $i < count($headers); ++$i)
{
	
$string = imap_fetchbody($mbox, $i+1, 1);
echo $string;
  
}

任何想法?

1 个答案:

答案 0 :(得分:0)

我自己找到了解决方案。似乎这些消息带有不同的Mime类型等。所以这个功能有助于找到mime类型并提供一个简单的&#34; getBody&#34;功能 - 请参阅此页:

https://www.sitepoint.com/exploring-phps-imap-library-1/