【问题标题】:php extracting text/plain from mail bodyphp从邮件正文中提取文本/纯文本
【发布时间】:2011-10-09 16:59:15
【问题描述】:

这是 imap_php 库读取的一封邮件的内容。 我会提取内容类型的文本/纯文本; 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 {"data":"10/10/2011","re​​gione":"pt","provincia":"pistoia","nome":"nome","tel":"12345","email":" mymailaddress","richiesta":"qualcosa"}

--20cf301e2f27a218c204a88578aa Content-Type: text/html; charset=ISO-8859-1 内容传输编码:引用打印 {"data&= quot;:"10/10/2011","re​​gione":"pt","provi= ncia":"pistoia","nome":"nome","tel&= quot;:"12345","email":"mymailaddress","r= ichiesta":"qualcosa"} --20cf301e2f27a218c204a88578aa--

如果我想要文本/纯正文,我必须使用什么? 谢谢。

【问题讨论】:

标签: php email imap


【解决方案1】:

你也可以试试这些

content-type:text/html

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

content-type:plaintext/text

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

关于imap_fetchbody的更多解释

【讨论】:

  • 如果 1.1 和 1.2 没有产生内容,我会退回到这个。
【解决方案2】:

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

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

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

【讨论】:

    猜你喜欢
    • 2015-11-05
    • 2011-05-15
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    • 2016-07-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多