我想使用 Zend_Mail_Storage_Imap 从 imap 获取电子邮件。当我获得内容时,我看不到波兰语字符。邮件:
coś tam coś tam
使用 Zend_Mail_Message 的内容:
co=B6 谭 co=B6 谭
我的代码:
foreach($imap as $messageNum=>$message)
{
if($message->isMultipart())
{
$con = array(
'content_type' => null,
'encoding' => null,
'text' => null,
);
foreach (new RecursiveIteratorIterator($message) as $part)
{
$con['encoding'] = $part->getHeaderField('content-type', 'charset');
$content_type = strtok($part->contentType, ';');
if(!$con['content_type'])
{
$con['content_type'] = $content_type;
$con['text'] = $part->getContent();
}
else
{
if($content_type == 'text/html')
{
$con['content_type'] = $content_type;
$con['text'] = $part->getContent();
}
}
}
$content = $con['text'];
if(strtolower($con['encoding']) != 'utf-8')
$content = iconv($con['encoding'], 'utf-8', $con['text']);
}
else
{
var_dump($message->getContent());
}
}