0

使用 php IMAP 时出现垃圾字符

<b>Text in bold</b> getting converted to *Text in bold* 
 words like shouldn't are getting converted to shouldn=92t

我正在使用的代码是

$inbox = imap_open('host', 'un', 'pw') or die('Cannot connect to Mail box: ' . print_r(imap_errors()));
$mails = imap_search($inbox,'UNSEEN');
if($mails) {
    foreach($mails as $mail) {
        echo $message = imap_fetchbody($inbox, $mail, 1);
        echo "<br><br>";
    }
}
imap_close($inbox);

有人可以帮我找出问题所在吗?

4

1 回答 1

2

您遇到两个不同的问题:

粗体文本只是因为邮件中的 html 是由浏览器解释的。为避免这种情况,您可以使用htmlentities()htmlspecialchars()转义内容

"shouldn=92t" 是带引号的可打印编码字符串。这必须被解码为可读 - 可以使用quoted_printable_decode()imap_qprint()

于 2013-09-30T23:27:07.887 回答