Php extract text / plain from mail body

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

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

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

- 20cf301e2f27a218c204a88578aa Content-Type: text / plain; Encoding = ISO-8859-1 {"Data": "10.10.2011", "Regione": "Fri", "Provincia": "Pistoia", "Noma": "Noma", "Body": "12345", "email": "mymailaddress", "Richiesta": "qualcosa"}

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

So what should I use if I want text / body? Thank.

+5
source share
2 answers

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

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

How to use IMAP in PHP to get mail body content?

+5
source

content-type:text/html

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

content-type:plaintext/text

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

imap_fetchbody

+4

All Articles