php imap不读取没有附件的正文消息

php imap不读取没有附件的正文消息,php,imap,Php,Imap,我已经为阅读电子邮件编写了php代码。我正在使用 imap_fetchbody($this->conn, $i, 1.2); $body = imap_fetchbody($this->conn, $i, 1); $body = imap_body($this->conn, $i); 用于显示电子邮件消息。当邮件带有附件时,它会以礼貌的方式显示,但如果邮件没有附件,它将不显示任何内容。当我使用 imap_fetchbody($this->conn, $i, 1.2)

我已经为阅读电子邮件编写了php代码。我正在使用

imap_fetchbody($this->conn, $i, 1.2);
$body = imap_fetchbody($this->conn, $i, 1);
$body = imap_body($this->conn, $i);
用于显示电子邮件消息。当邮件带有附件时,它会以礼貌的方式显示,但如果邮件没有附件,它将不显示任何内容。当我使用

imap_fetchbody($this->conn, $i, 1.2);
$body = imap_fetchbody($this->conn, $i, 1);
$body = imap_body($this->conn, $i);
消息以文本/普通格式显示。像这样

this is system generated mail -- Regards! Md Belal 
--047d7b5d2f88ddb36c050069a175 Content-Type: text/plain; charset=UTF-8 this is system generated mail -- Regards! Md Belal 8287326270 --047d7b5d2f88ddb36c050069a175 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 

this is system generated mail

-- 


Regards!
Md Belal
--047d7b5d2f88ddb36c050069a175--
当我使用

imap_fetchbody($this->conn, $i, 1.2);
$body = imap_fetchbody($this->conn, $i, 1);
$body = imap_body($this->conn, $i);
它是这样显示的

this is system generated mail -- Regards! Md Belal 
--047d7b5d2f88ddb36c050069a175 Content-Type: text/plain; charset=UTF-8 this is system generated mail -- Regards! Md Belal 8287326270 --047d7b5d2f88ddb36c050069a175 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 

this is system generated mail

-- 


Regards!
Md Belal
--047d7b5d2f88ddb36c050069a175--
我需要有礼貌地展示它。像这样

this is system generated mail

-- 


Regards!
Md Belal
做什么请帮忙。谢谢

试试这个


顺便说一句,我还没有尝试过,但nl2br可能也可以帮助您,当您的结果为文本/纯格式且包含\n\r字符时,它会添加换行符。

不完全显示为邮件,但显示附件时,显示效果仍然比以前更好。谢谢,顺便说一句。你需要获取主体结构,解析它,然后决定主体是什么。电子邮件可以以多种方式发送,1.2并不总是主体,甚至可能不存在。例如,如果电子邮件仅为纯文本或html,则它将只有一部分。