php从邮件正文中提取文本/纯文本

发布于 2024-11-25 02:08:00 字数 898 浏览 0 评论 0原文

这是 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","re​​gione":"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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦初启 2024-12-02 02:08:00

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

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

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

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?

愿与i 2024-12-02 02:08:00

您还可以尝试这些

content-type:text/html

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

content-type:plaintext/text

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

有关 imap_fetchbody 的更多说明

You Can also try these

content-type:text/html

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

content-type:plaintext/text

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

More explanation about imap_fetchbody

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文