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"}
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 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 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.
You need to use 1.1 as the section argument to fetch_body() For example:
$message = imap_fetchbody($inbox,$email_number, 1.1);
How to use IMAP in PHP to fetch mail body content?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With