php提取文本/从邮件正文

问题描述:

这是imap_php库读取的一个邮件的内容。
我将提取content-type text / plain; charset = ISO-8859-1文本:

this is the content of one mail read by imap_php library. I would extract the content-type text/plain; charset=ISO-8859-1 text:

{"data":"10/10/2011","regione":"pt","provincia":"pistoia","nome":"nome","tel":"12345","email":"mymailaddress","richiesta":"qualcosa"}

如果我使用imap_body($ mbox,$ result [0]),我已经返回框中的所有文本。
如果我使用imap_fetchbody($ mbox,$ email_number,2);我已经返回了我不想要的text / html正文消息。

If I use imap_body($mbox, $result[0]) i have returned all the text in the box. If I use imap_fetchbody($mbox,$email_number,2); I have returned the text/html body message that i don't want.


- 20cf301e2f27a218c204a88578aa内容类型:text / plain;
charset = ISO-8859-1
{data:10/10/2011,regione:pt,provincia:pistoia,nome ,tel:12345,email:mymailaddress,richiesta:qualcosa}

--20cf301e2f27a218c204a88578aa Content-Type: text/plain; charset=ISO-8859-1 {"data":"10/10/2011","regione":"pt","provincia":"pistoia","nome":"nome","tel":"12345","email":"mymailaddress","richiesta":"qualcosa"}

- 20cf301e2f27a218c204a88578aa内容类型: HTML;
charset = ISO-8859-1 Content-Transfer-Encoding:quoted-printable
{data& =:10/10/2011,regione:pt,provi =
ncia:pistoia,nome:nome,tel& =
quot;:12345,email:mymailaddress,r = ichiesta
--20cf301e2f27a218c204a88578aa -

--20cf301e2f27a218c204a88578aa Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable {"data&= quot;:"10/10/2011","regione":"pt","provi= ncia":"pistoia","nome":"nome","tel&= quot;:"12345","email":"mymailaddress","r= ichiesta":"qualcosa"} --20cf301e2f27a218c204a88578aa--

那么如果我想要文字/纯正的身体,我必须使用什么?
谢谢。

So what I have to use if I want the text/plain body? Thanks.

您需要使用1.1作为fetch_body()的部分参数
例如:

You need to use 1.1 as the section argument to fetch_body() For example:

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

如何在PHP中使用IMAP来获取邮件正文内容?