imap_body
并非对我来说不正确,请告诉我我做错了什么。
错误消息带有文本:
“-0000000000007f934b0574cac3e4内容类型:文本/纯文本; charset =“ UTF-8” cxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz --0000000000007f934b0574cac3e4内容类型:text / html; charset =“ UTF-8” cxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz --0000000000007f934b0574cac3e4--“
但这应该只是
“ cxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz”
我的代码是:
function display_message($auth_user, $accountid, $messageid, $fullheaders) {
$buttons = array();
$buttons[0] = 'reply';
$buttons[1] = 'reply-all';
$buttons[2] = 'forward';
$buttons[3] = 'delete';
$buttons[4] = 'show-headers';
$message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
if(count($message)==0) {
echo "cannot retrieve message number $messageid".'.<br />';
} else {
$imap =open_mailbox($auth_user, $accountid); ?>
<table>
<tr>
<td>
<b> Subject: </b>
</td>
<td>
<b> <?php echo iconv_mime_decode($message['subject']);?> </b>
</td>
</tr>
<tr>
<td>
<b> From: </b>
</td>
<td>
<b> <?php echo iconv_mime_decode($message['fromaddress']);?> </b>
</td>
</tr>
<tr>
<td>
<b> To: </b>
</td>
<td>
<b> <?php echo iconv_mime_decode($message['toaddress']);?> </b>
</td>
</tr>
<td>
<b> Received: </b>
</td>
<td>
<b> <?php echo iconv("cp1251", "UTF-8", strftime($message['date'])); ?> </b>
</td>
</tr>
</table>
<?php display_toolbar($buttons, "&messageid=$messageid"); ?>
<table>
<tr>
<td>
<?php echo iconv_mime_decode($message['fullheaders']); ?>
</td>
</tr>
</table>
<table>
<tr>
<td>
<?php echo $message['body']; ?>
</td>
</tr>
</table>
<?php
}
}
retrieve_message
函数是:
function retrieve_message($auth_user, $accountid, $messageid, $fullheaders) {
$message = array();
if(!($auth_user && $messageid && $accountid)) {
var_dump(1);
return false;
}
$imap = open_mailbox($auth_user, $accountid);
if(!$imap) {
return false;
}
$header = imap_header($imap, $messageid);
if(!$header) {
return false;
}
$message['body'] = imap_body($imap, $messageid));
if(!$message['body']) {
$message['body'] = "[This message has no body]\n\n\n\n\n\n";
}
if($fullheaders) {
$message['fullheaders'] = imap_fetchheader($imap, $messageid);
} else {
$message['fullheaders'] = '';
}
$message['subject'] = $header->subject;
$message['fromaddress'] = $header->fromaddress;
$message['toaddress'] = $header->toaddress;
$message['date'] = $header->date;
// note we can get more detailed information by using from and to
// rather than fromaddress and toaddress, but these are easier
imap_close($imap);
return $message;
}