【发布时间】:2017-10-13 14:49:30
【问题描述】:
我需要解析邮件 从后缀接收 在 php 结构中,例如 headers 数组、纯文本/文本正文字符串和 html 正文字符串。
我正在测试来自https://www.thecodingmachine.com/triggering-a-php-script-when-your-postfix-server-receives-a-mail/ 的示例,以接收所有发送给我的 php 脚本的信件。但是此页面中的示例已被放弃或无法按我的意愿工作。
我想要类似的东西:
$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)
【问题讨论】:
-
你有什么要开始的吗?您是否尝试过使用像这样的正则表达式 preg_match("/(From:)(.*)()/", $input_line, $output_array);
-
特拉卡莱尔·拉蒙·路易斯,哈哈。不!
-
StackOverflow 不是我们为您完成所有工作的网站。如果您在尝试某事后遇到特定问题,那么您可以提出要求,我们会尽力帮助您,但我们不会像那样为您解决这样的问题。
-
我并不是要为我解决问题。此外,我可能已经找到了自己的解决方案,形式为 php-mime-mail-parser 包。
标签: php email parsing mime postfix