PHP IMAP电子邮件正文阅读


php imap email body reading

我通过 imap 收到我的电子邮件,但在我的收件箱中卡住了一封电子邮件,里面有字母 Â,而 imap 不会得到它的正文。 其余的电子邮件将阅读正常。它的标题很好,它会读。

我如何获得带有这种信件的电子邮件正文

代码示例在这里

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to mail server: ' . imap_last_error());
$emails = imap_search($inbox,'SUBJECT "UKPF - New Booking"'); 
$overview = imap_fetch_overview($inbox,$email_number,0);
$message  = imap_fetchbody($inbox,$email_number,2);

我已经使用这个引用的可打印解码php函数解决了这个问题。在您的情况下:

$message = quoted_printable_decode($imap_fetchbody($inbox,$email_number,2));

我曾经在我的 php 形式中也遇到某些字符的问题,这很有帮助:

我把这个

"MIME-Version: 1.0; Content-Type: text/plain; charset=utf-8"

mail()参数中。我不知道 imap 是什么或它的工作原理有何不同,但希望这会有所帮助。