php从邮件正文中提取文本/纯文本
这是 imap_php 库读取的一封邮件的内容。 我会提取内容类型 text/plain; charset=ISO-8859-1 文本:
{"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 正文消息。
--20cf301e2f27a218c204a88578aa 内容类型:文本/纯文本; 字符集=ISO-8859-1 {“数据”:“10/10/2011”,“地区”:“pt”,“省”:“皮斯托亚”,“诺姆”:“诺姆”,“电话”:“12345”,“电子邮件”:“ mymailaddress","richiesta":"qualcosa"}
--20cf301e2f27a218c204a88578aa 内容类型:text/html; 字符集 = ISO-8859-1 内容传输编码:引用打印 {"data&= quot;:"10/10/2011","regione":"pt","provi= ncia":"皮斯托亚","诺姆":"诺姆","电话&= quot;:"12345","电子邮件":"mymailaddress","r= ichiesta":"qualcosa"} --20cf301e2f27a218c204a88578aa--
那么如果我想要文本/纯文本正文,我必须使用什么? 谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 1.1 作为 fetch_body() 的节参数
例如:
如何在 PHP 中使用 IMAP获取邮件正文内容?
You need to use 1.1 as the section argument to fetch_body()
For example:
How to use IMAP in PHP to fetch mail body content?
您还可以尝试这些
有关 imap_fetchbody 的更多说明
You Can also try these
More explanation about imap_fetchbody