如何从原始电子邮件中提取回复电子邮件
我正在使用 imap 来抓取电子邮件并将它们插入到 mysql 数据库中。但我不希望包含原始电子邮件。
假设我发送了一封包含以下内容的电子邮件: 你好,天气怎么样。
然后你回应 天气很好
php 从 Imap 读取的电子邮件如下所示: 天气真好 你好,天气怎么样。
有没有办法删除原来的消息“你好,天气怎么样。”?
我对这些东西不太了解,可能需要非常清楚地解释。谢谢!
I am using imap to grap emails and insert them into a mysql database. But I don't want the original email included.
So lets say I send out an email that contains this:
Hello, How is the weather.
And then you respond
The weather is great
The email that php reads from Imap looks like this:
The weather is great
Hello, How is the weather.
Is there away to remove the orginal message, "Hello, How is the weather."?
I am not to savvy on this stuff and will probably need things explained very clearly. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有。由于没有标准的回复方式(即,有些人使用 >,有些人使用 |,有些人顶帖,有些人混合,有些人附加),因此无法准确可靠地拉出原始内容。您可以摆弄正则表达式来捕获一些更常见的情况,但我认为您会发现这条路线的麻烦远远超过其价值。
Nope. Since there is no standard way to reply (i.e., some people use >, some use |, some top-post, some intermix, some attach) there's no way to accurately and reliably pull out the original. You could fiddle with regexp to catch some of the more common cases, but I think you'll find that route to be far more trouble than it's worth.
据我所知,没有万无一失的方法可以做到这一点。当您回复电子邮件时,MUA 有权按照其认为合适的方式重新格式化原始邮件。例如,Outlook 可能会将原始文本转换为 HTML 并添加不可见的标签。
如果您有权访问整个电子邮件线程,您也许能够根据主题或标题给您的任何提示找到原始邮件。
这都是 AFAIK,所以如果我错了,请有人纠正我。
To my knowledge, there is no foolproof way to do this. When you reply to an email, the MUA has the right to reformat the original message as it sees fit. For example, Outlook may convert the original text to HTML and add invisible tags.
If you have access to the whole email thread, you may be able to find the original message based on subject or any hints that the headers give you.
This is all AFAIK, so someone please correct me if I am wrong.
当您来回发送同一主题的多封电子邮件时,您可以像 Gmail 那样进行操作。
只需保留您发送的电子邮件的副本,然后当您收到回复时,查找类似的文本或 Gmail 所指的“引用文本”。
或者您可以根据他们的电子邮件域查找某些模式。然而,没有一个答案是 100% 有效的。这一切都只是基于您的最佳猜测。
You could do what Gmail does when you are sending multiple emails back and forth with the same subject.
Just keep a copy of the email that you send and then when you get a reply, look for similar text or as Gmail refers to it: "quoted text".
Or you can look for certain patterns based on their email domain. However, there is no answer that will work 100% of the time; it is all just based on your best guess.