PHP imap读取正文消息


php imap reading body message

我正在写一个简单的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-- 

如何只提取:?我使用的是php_imap

谢谢。

如果您正在使用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);

如果将来有人问同样的问题,这段代码为我工作:

imap_fetchbody($this->connection, $sequence, 1);