2011-07-20 124 views
3

我正在为阅读邮件写一个简单的php脚本。php imap阅读正文消息

当我中提取邮件体:

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-- 

如何我只能提取? 我正在使用php_imap。

谢谢。

回答

3

如果您使用的是IMAP,则可以使用imap_body()函数来读取正文。 PHP有很多功能可以帮助您解析电子邮件。

http://www.php.net/manual/en/ref.imap.php

退房的fetch_body()函数了。它会让你得到身体的一部分。

http://www.php.net/manual/en/function.imap-fetchbody.php

例如:

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

问题是,整个字符串由imap_body印刷($ MBOX,$ⅰ); – michele

+0

你尝试过fetch_body()吗? 'imap_fetchbody(resource $ imap_stream,int $ msg_number,string $ section [,int $ options = 0])' 该部分是您可以发送以获取主体的参数。 – serialworm

+0

这可能有所帮助。 http://stackoverflow.com/questions/5177772/how-to-use-imap-in-php-to-fetch-mail-body-content – serialworm