php imap读取正文消息

php imap读取正文消息,php,email,Php,Email,我正在编写一个用于阅读电子邮件的简单php脚本 当我提取邮件正文时,使用: imap_body($mbox, $i); 我返回了这样的内容: --0016e6db2b334d4d7904a883f4ec Content-Type: text/plain; charset=ISO-8859-1 <The message arrived> --0016e6db2b334d4d7904a883f4ec Content-Type: text/html; charset=ISO-

我正在编写一个用于阅读电子邮件的简单php脚本

当我提取邮件正文时,使用:

imap_body($mbox, $i);
我返回了这样的内容:

--0016e6db2b334d4d7904a883f4ec 
Content-Type: text/plain; charset=ISO-8859-1 

<The message arrived> 

--0016e6db2b334d4d7904a883f4ec 
Content-Type: text/html; charset=ISO-8859-1 

<The message arrived> 

--0016e6db2b334d4d7904a883f4ec-- 
--0016e6db2b334d4d7904a883f4ec
内容类型:文本/纯文本;字符集=ISO-8859-1
--0016e6db2b334d4d7904a883f4ec
内容类型:text/html;字符集=ISO-8859-1
--0016e6db2b334d4d7904a883f4ec--
我怎样才能只提取:? 我正在使用php_imap


谢谢。

如果使用IMAP,可以使用IMAP_body()函数读取正文。 PHP有很多函数可以帮助您解析电子邮件

还可以查看fetch_body()函数。它会让你只得到身体的一部分

例如:

$message = imap_fetchbody($inbox,$email_number, 1.2);

问题是整个字符串由imap_body($mbox,$i)打印;您是否尝试过获取_body()
imap\u fetchbody(资源$imap\u stream,int$msg\u number,string$section[,int$options=0])
section是可以发送以获取主体的参数。这可能会有所帮助。我用一个示例编辑了我的原始答案,该示例演示了如何使用fetch_body()从电子邮件中提取html文本