Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php extracting text/plain from mail body

Tags:

php

email

imap

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.

like image 934
michele Avatar asked Jul 20 '11 19:07

michele


1 Answers

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?

like image 98
serialworm Avatar answered Sep 28 '22 04:09

serialworm