gpt4 book ai didi

php - 如何从 POP3 电子邮件中提取数据?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:03:13 25 4
gpt4 key购买 nike

我使用 PHP 从 POP3 服务器接收电子邮件。我有一个包含标题和正文的原始字符串。如何以类或数组的形式解析标题和正文?

我所拥有的示例:

Return-path: Envelope-to: x@x.de Delivery-date:
Wed, 06 Feb 2013 09:35:37 +0100 Received: from mail by
host6.toxpress.com with spam-scanned (Exim 4.80.1) (envelope-from ) id
1U30Tc-0003sH-LQ for x@x.de; Wed, 06 Feb 2013
09:35:36 +0100 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06)
on host6.toxpress.com X-Spam-Level: X-Spam-Status: No, score=-1.9
required=5.0 tests=BAYES_00,FREEMAIL_FROM,
RCVD_IN_DNSWL_NONE,TVD_SPACE_RATIO autolearn=ham version=3.3.2
Received: from moh3-ve2.go2.pl ([193.17.41.86] helo=moh3-ve1.go2.pl)
by host6.toxpress.com with esmtp (Exim 4.80.1) (envelope-from ) id
1U30Tc-0003rk-2b for x@x.de; Wed, 06 Feb 2013
09:35:32 +0100 Received: from moh3-ve1.go2.pl (unknown [10.0.0.157])
by moh3-ve1.go2.pl (Postfix) with ESMTP id BC734AF611B for ; Wed, 6
Feb 2013 09:34:31 +0100 (CET) Received: from unknown (unknown
[10.0.0.108]) by moh3-ve1.go2.pl (Postfix) with SMTP for ; Wed, 6 Feb
2013 09:34:31 +0100 (CET) Received: from
43.dynamic.chello.pl [89.69.42.127] by poczta.o2.pl with
ESMTP id jtIGfv; Wed, 06 Feb 2013 09:34:31 +0100 Message-ID:
<51121593.3090008@o2.pl> Date: Wed, 06 Feb 2013 09:34:27 +0100 From:
Tomasz Reply-To: tomasz_smykrowski@o2.pl Organization: Tomasz
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101
Thunderbird/20.0a2 MIME-Version: 1.0 To: x@x.de
Subject: adaads Content-Type: text/plain; charset=ISO-8859-1;
format=flowed Content-Transfer-Encoding: 7bit X-O2-Trust: 2, 64
X-O2-SPF: neutral dsadasdsaas .

我想做的事:

echo $from;
echo $replyTo;
echo $date;
echo $body;
echo $subject;
echo $charset;

最佳答案

看看 MIME E-mail message parser类。
根据作者的描述:

This class can be used to parse and decode MIME e-mail messages. It supports decoding single RFC 2822 MIME messages or archives that aggregate multiple messages in the mbox format. The decoded message data is returned as an array that describes one or more messages found in a message file or data string. The bodies of multipart messages can be decoded into distinct sub-messages. The message body data can decoded and saved to separate files, so the class can handle messages larger than the available memory.

关于php - 如何从 POP3 电子邮件中提取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14725067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com