问题描述
我有这个代码.它来自 Zend 阅读邮件 示例.
I have this code. It's from the Zend Reading Mail example.
$message = $mail->getMessage(1);
// output first text/plain part
$foundPart = null;
foreach (new RecursiveIteratorIterator($mail->getMessage(1)) as $part) {
try {
if (strtok($part->contentType, ';') == 'text/plain') {
$foundPart = $part;
break;
}
} catch (Zend_Mail_Exception $e) {
// ignore
}
}
if (!$foundPart) {
echo 'no plain text part found';
} else {
echo $foundPart->getContent();
}
我能得到的是消息,效果很好.但是试图将消息解码为可读的内容是行不通的.我试过 Zend_Mime、imap_mime 和 iconv 都没有运气.
What I can get is the message, that works fine. But trying to decode the message into something readable does not work. I have tried Zend_Mime, imap_mime and iconv with no luck.
这是我使用 $foundPart->getContent();
Hall=F3 heim=FAr
应该说Haló heimúr"
It should say "Halló heimúr"
我想要的只是一些图书馆,在那里我可以在实践中按下按钮,接收培根".我的意思是,我只想将库指向 POP3 邮箱,并以可读形式(没有任何编码问题)和附件获取电子邮件.
What I would want is just some library where i could "push button, receive bacon" in practice. What I mean is, I just want to point the library to a POP3 email box and get the email in readable form (without any encoding issues) and the attachments.
imap_mime_header_decode()
给我一个具有相同数据的数组.iconv_ mime_ decode()
一样的
imap_mime_header_decode()
Gives me an array with the same data.iconv_ mime_ decode()
Does the same
有没有人知道为什么会发生这种情况或者我可以将其抽象出来的某个库(PHP/Python 或 Perl)
Does anyone have any idea why this is happening or some library where I can just abstract this away (PHP/Python or Perl)
推荐答案
这可能是因为 base64 编码.Zend_Mail 文档说(在编码"下):
This could be because of base64 encoding. The Zend_Mail docs say (under 'encoding'):
...所有其他附件都已编码如果没有其他编码,则通过 base64在 addAttachment() 调用中给出或分配给 MIME 部件对象稍后.
尝试以下操作:
echo base64_decode($foundPart->getContent());
另外,请阅读:http://framework.zend.com/manual/en/zend.mail.encoding.html
希望以某种方式有所帮助.
Hope that helped somehow.
这篇关于为什么此邮件消息不能正确解码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!