Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 邮戳-清理已解析的电子邮件_Python_Json_Parsing_Email - Fatal编程技术网

Python 邮戳-清理已解析的电子邮件

Python 邮戳-清理已解析的电子邮件,python,json,parsing,email,Python,Json,Parsing,Email,我希望我的客户能够通过电子邮件回复。我正在查看传入的电子邮件解析器,例如邮戳,但它们似乎在电子邮件中包含所有嵌套的回复和附加的标题信息,而不仅仅是新内容 到目前为止,我使用这种方法: clean_index = text.find('Respond by replying to this message above this line.') if clean_index != -1 and clean_index > 1: new_text = text[:clean_index]

我希望我的客户能够通过电子邮件回复。我正在查看传入的电子邮件解析器,例如邮戳,但它们似乎在电子邮件中包含所有嵌套的回复和附加的标题信息,而不仅仅是新内容

到目前为止,我使用这种方法:

clean_index = text.find('Respond by replying to this message above this line.')
if clean_index != -1 and clean_index > 1:
    new_text = text[:clean_index]
else:
    new_text = text
return new_text
然而,每个电子邮件客户端在回复电子邮件时似乎都会做一些不同的事情。例如,当您点击“回复”时,hotmail会在上一封电子邮件的上方添加此标记:

My typed new message......
From: test@hotmail.com
To: q3vxif_e+lj9p@inbound.test.com
Subject: RE: hhj - test
Date: Sat, 26 Apr 2014 16:42:51 +0100
Respond by replying to this message above this line.
这意味着回复中包含了所有这些额外的垃圾,而不仅仅是消息本身

问题
我的问题是,在隔离电子邮件中的新邮件时,是否有“一刀切”的方法来删除所有其他无用信息?

不幸的是,没有一刀切的方法。主要是因为您指出的问题——每个提供者(本例中为MUA)都遵循自己的格式

您可以借用处理类似情况的现有开源项目。Github允许人们通过电子邮件回复问题,并且他们可以开源


(Gitlab。)

邮戳应用程序现在支持回复解析。解析的内容位于StrippedTextReply属性中

邮戳文档的限制:

StrippedTextReply字段仅限于英文文本回复,并且 目前已在以下电子邮件平台上测试:雅虎、iCloud、, Gmail、Outlook.com、iOS Mail、Apple Mail、Microsoft Outlook(Windows& Mac)和Mozilla Thunderbird。邮戳是“最好的尝试” 解析所有入站回复

看看