从 php 中的 postfix 解析邮件数据(搜索 mime-parser/decoder class)
Parse mail data from postfix in php (search mime-parser/decoder class)
我需要解析邮件 从后缀收到php结构像 headers 数组,plain/text body 字符串和 html body 字符串。
我正在测试 https://www.thecodingmachine.com/triggering-a-php-script-when-your-postfix-server-receives-a-mail/ 中的示例,以接收所有发送至我的 php-script 的信件。但是此页面中的示例已被放弃或无法正常工作。
我想要这样的东西:
$message_from_postfix = "Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by DavidUbuntu (Postfix) with ESMTPS id 740AD380597
for <david@localhost>; Thu, 5 Jan 2012 10:04:48 +0100 (CET)
Message-ID: <1325754288.4989.6.camel@DavidUbuntu>
Subject: my title
From: David Negrier <david@localhost>
To: david@localhost
Date: Thu, 05 Jan 2012 10:04:48 +0100
Content-Type: text/plain
X-Mailer: Evolution 3.2.0-
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0
my mail content";
$data = ParseMessage($message_from_postfix);
echo $data->headers()['from']; // david@localhost
echo $data->headers()['to']; // david@localhost
echo $data->headers()['date']; // 1325757888
echo $data->text_message(); // my mail content
echo $data->html_message(); // (empty)
我发现:https://github.com/php-mime-mail-parser/php-mime-mail-parser
这对我来说可能是最好的解决方案。
我需要解析邮件 从后缀收到php结构像 headers 数组,plain/text body 字符串和 html body 字符串。
我正在测试 https://www.thecodingmachine.com/triggering-a-php-script-when-your-postfix-server-receives-a-mail/ 中的示例,以接收所有发送至我的 php-script 的信件。但是此页面中的示例已被放弃或无法正常工作。
我想要这样的东西:
$message_from_postfix = "Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by DavidUbuntu (Postfix) with ESMTPS id 740AD380597
for <david@localhost>; Thu, 5 Jan 2012 10:04:48 +0100 (CET)
Message-ID: <1325754288.4989.6.camel@DavidUbuntu>
Subject: my title
From: David Negrier <david@localhost>
To: david@localhost
Date: Thu, 05 Jan 2012 10:04:48 +0100
Content-Type: text/plain
X-Mailer: Evolution 3.2.0-
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0
my mail content";
$data = ParseMessage($message_from_postfix);
echo $data->headers()['from']; // david@localhost
echo $data->headers()['to']; // david@localhost
echo $data->headers()['date']; // 1325757888
echo $data->text_message(); // my mail content
echo $data->html_message(); // (empty)
我发现:https://github.com/php-mime-mail-parser/php-mime-mail-parser
这对我来说可能是最好的解决方案。