PHP 中的电子邮件、消息线程、正则表达式可能需要
我正在研究记录发送到特定地址的电子邮件的东西。我有一个 PHP 脚本,可以将信息放入 MySql 中,该脚本运行良好。
我需要能够基于类似于 Gmail 的“对话”对消息进行分组,并且已经对此进行了一些阅读。这不需要是完美的,因为消息在显示在网站上之前将被手动批准,然后可以纠正任何错误。我只是想让工作量尽可能减少,以便将新电子邮件链接到原始电子邮件应该自动完成。
我的理解是,In-Reply-To
标头可以识别原始消息,但其使用并不标准。
我在另一页上找到了这一点:
The most common forms of In-Reply-To seemed to be:
31% NAME's message of TIME <ID@HOST>
22% <ID@HOST>
9% <ID@HOST> from NAME at "TIME"
8% USER's message of TIME <ID@HOST>
7% USER's message of TIME
6% Your message of "TIME"
17% hundreds of other variants (average 0.4% each?)
但是,这似乎表明假设如果有 In-Reply-To 字段,则其中找到的第一个 <>
括起来的文本并不是没有道理的是父消息的消息 ID。
那么,获得该值的最简单方法是什么?是否有一个正则表达式可以让我抓取 <
和 >
内的任何内容(如果可用)? (根据我发现的帖子,这应该是 <
和 >
中的第一个值吗?)
感谢您提供的任何帮助。
I'm working on something that logs e-mail messages sent to a certain address. I have a PHP script that puts the info into MySql, which is working fine.
I need to be able to group messages based on the 'conversation' similar to Gmail, and have already read up on this a bit. This doesn't need to be perfect because messages will be manually approved before being shown on the website, and any errors can be corrected then. I just want to make it the least amount of work as possible so that linking a new e-mail to the original should be done automatically.
My understanding is that the In-Reply-To
header can identify the original message, but that its use is not standard.
I found this on another page:
The most common forms of In-Reply-To seemed to be:
31% NAME's message of TIME <ID@HOST>
22% <ID@HOST>
9% <ID@HOST> from NAME at "TIME"
8% USER's message of TIME <ID@HOST>
7% USER's message of TIME
6% Your message of "TIME"
17% hundreds of other variants (average 0.4% each?)
However, this seems to indicate that it's not unreasonable to assume that, if there is an In-Reply-To field, then the first <>
bracketed text found therein is the Message-ID of the parent message.
So, what is the easiest way to get that value? Is there a regular expression that would let me grab whatever is inside the <
and >
if is is available? (According to the post I found, should this be the FIRST value inside a <
and >
?)
Thanks for any help you can provide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够抓住反向引用中的第一个匹配项:
<(.+)>
说明:
根据 此文档 您可以编写如下内容来完成您想做的事情(如果这不是有效的 php,请原谅我):
You should be able to just grab the first match in the back-reference:
<(.+)>
Explanation:
According to this documentation you could write something like as follows to accomplish what you want to do (forgive me if this is not valid php):