Email 关于苹果邮件的文档';emlx数据结构(用于转换目的)?
这似乎是一块罕见的宝石:在哪里可以找到有关Apple Mail的.emlx文件结构的文档(及其部分变体,以及目录结构的含义)。这些文档在苹果的网站上似乎不存在,我也无法通过谷歌找到任何合理的提及 这里的要点是创建一个bash/ruby/python/insert脚本langauge-here脚本,将这些混乱的文件转换成一些可用的/易用的文件,如Maildir或Mbox。最终目标是将用户/库/邮件存储的快照迁移到现有的Dovecot设置中,该设置使用Maildir的形式 是的,但它没有解决我所追求的解决方案。手动转换20个邮箱并手动将其插入现有安装将需要更多的时间,而不仅仅是编写一个脚本,将消息分解为其他内容,然后自动将其存储在应该的位置。尽管可能还有六个以上的用户需要这个过程。所以我花时间来写剧本是值得的 请在该问题待删除期间投票关闭该问题的副本,而不是投票关闭该问题。由于某些原因,当使用Chrome作为浏览器时,偶尔会出现发布问题Email 关于苹果邮件的文档';emlx数据结构(用于转换目的)?,email,data-structures,apple-mail,Email,Data Structures,Apple Mail,这似乎是一块罕见的宝石:在哪里可以找到有关Apple Mail的.emlx文件结构的文档(及其部分变体,以及目录结构的含义)。这些文档在苹果的网站上似乎不存在,我也无法通过谷歌找到任何合理的提及 这里的要点是创建一个bash/ruby/python/insert脚本langauge-here脚本,将这些混乱的文件转换成一些可用的/易用的文件,如Maildir或Mbox。最终目标是将用户/库/邮件存储的快照迁移到现有的Dovecot设置中,该设置使用Maildir的形式 是的,但它没有解决我所追求
后续:看来该格式确实没有文档记录,而且大多数来源都对其进行了反向工程。如果我有时间,我会尝试自己去做;如果我成功了,我将发布第二次后续报告,详细介绍我的发现。这是一个ruby中的emlx2mbox转换器:
我不认为它是从规范的任何文档中编写的,但是它已经经历了多次更新,所以希望它能够至少处理一些格式上的怪癖。源代码大约有250行长,看起来可读性强,注释也很好。关于emlx格式的更多信息 委员会:
- 第一行消息的字节计数
- 消息的MIME转储
- XML plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>date-sent</key>
<real>1362211252</real>
<key>flags</key>
<integer>8590195713</integer>
<key>original-mailbox</key>
<string>imap://****@127.0.0.1:143/mail/2013/03</string>
<key>remote-id</key>
<string>252</string>
<key>subject</key>
<string>Re: Foobar</string>
</dict>
我正在使用mailcore2解析.eml消息。为了使用.emlx实现这一点,我只需删除第一行(包含一个数字)。消息本身具有消息的长度,因此不需要删除末尾的XML块 下面是我如何在objective-c/cocoa中实现的(McOmeMessageParser来自mailcore2框架):
到2020年,Python有了一个轻量级 然后
>>> import emlx
>>> m = emlx.read("12345.emlx")
>>> m.headers
{'Subject': 'Re: Emlx library ✉️',
'From': 'Michael <michael@example.com>',
'Date': 'Thu, 30 Jan 2020 20:25:43 +0100',
'Content-Type': 'text/plain; charset=utf-8',
...}
>>> m.headers['Subject']
'Re: Emlx library ✉️'
>>> m.plist
{'color': '000000',
'conversation-id': 12345,
'date-last-viewed': 1580423184,
'flags': {...},
...}
>>> m.flags
{'read': True, 'answered': True, 'attachment_count': 2}
导入emlx
>>>m=emlx.read(“12345.emlx”)
>>>m.headers
{'Subject':'Re:Emlx库✉️',
“From”:“Michael”,
“日期”:2020年1月30日星期四20:25:43+0100”,
“内容类型”:“文本/普通;字符集=utf-8”,
...}
>>>m.标题[“主题”]
'Re:Emlx库✉️'
>>>普利斯特先生
{'color':'000000',
“对话id”:12345,
“上次查看日期”:1580423184,
'标志':{…},
...}
>>>m.flags
{'read':True,'responsed':True,'attachment_count':2}
虽然它不是数据结构的文档,但至少是功能性源代码,+1表示正确方向的步骤。:)代码不产生任何可用的输出?啊!我的眼睛!护目镜!他们什么也不做!!!我怀疑没有关于emlx的公开文档,因为我见过的每一个emlx工具都表明它们对格式进行了反向工程。如果这个rb不起作用,我想你有幸制作了一个更好的版本。:)看来我就在这里。但感谢你至少发布了一个工具,在这方面需要一个裂缝。据我所知,有一个数字指示器(大小?),消息,然后是一些XML标记。我怀疑修剪XML、舍弃数字并保存其余部分可能会奏效感谢您在这方面的工作,但我一直无法读取emlx文件的plist部分。似乎包含一些未知来源的Python代码,大致实现了下面的答案。
875
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on ******.*********.***
X-Spam-Level:
X-Spam-Status: No, score=-3.2 required=4.2 tests=BAYES_00,RP_MATCHES_RCVD,
SPF_PASS,TVD_SPACE_RATIO autolearn=ham version=3.3.2
Received: from [127.0.0.1] (******.*********.*** [***.**.**.**])
by ******.*********.*** (8.14.5/8.14.5) with ESMTP id r2TN8m4U099571
for <****@*********.***>; Fri, 29 Mar 2013 19:08:48 -0400 (EDT)
(envelope-from ****@*********.***)
Subject: very simple
From: Karl Dubost <****@*********.***>
Content-Type: text/plain; charset=us-ascii
Message-Id: <4E83618E-BB56-404F-8595-87352648ADC7@*********.***>
Date: Fri, 29 Mar 2013 19:09:06 -0400
To: Karl Dubost <****@*********.***>
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Apple Message framework v1283)
X-Mailer: Apple Mail (2.1283)
message Foo
--
Karl Dubost
http://www.la-grange.net/karl/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>date-sent</key>
<real>1364598546</real>
<key>flags</key>
<integer>8590195713</integer>
<key>original-mailbox</key>
<string>imap://********@127.0.0.1:11143/mail/2013/03</string>
<key>remote-id</key>
<string>41147</string>
<key>subject</key>
<string>very simple</string>
</dict>
</plist>
-(Documents *)ParseEmlMessageforPath: (NSString*)fullpath filename:(NSString*)filename{
NSLog(@"fullpath = %@", fullpath);
NSError * error;
error = nil;
NSData *fileContents = [NSData dataWithContentsOfFile:fullpath options:NSDataReadingMappedIfSafe error:&error];
if (error) {
[[NSApplication sharedApplication] presentError:error];
}
MCOMessageParser * parser;
if (fileContents) {
if ([[fullpath pathExtension] isEqualToString:@"emlx"]) {
NSData * linefeed = [(NSString*)@"\n" dataUsingEncoding:NSUTF8StringEncoding ];
NSInteger filelength = [fileContents length];
NSRange xx = NSMakeRange(0, 20);
NSRange pos = [fileContents rangeOfData:linefeed options:0 range:xx] ;
if (pos.location != NSNotFound) {
NSData *subcontent = [fileContents subdataWithRange:(NSRange){pos.location+1, filelength-(pos.location)-1}];
parser = [MCOMessageParser messageParserWithData:subcontent];
} else {
return nil;
}
} else {
parser = [MCOMessageParser messageParserWithData:fileContents];
}
pip install emlx
>>> import emlx
>>> m = emlx.read("12345.emlx")
>>> m.headers
{'Subject': 'Re: Emlx library ✉️',
'From': 'Michael <michael@example.com>',
'Date': 'Thu, 30 Jan 2020 20:25:43 +0100',
'Content-Type': 'text/plain; charset=utf-8',
...}
>>> m.headers['Subject']
'Re: Emlx library ✉️'
>>> m.plist
{'color': '000000',
'conversation-id': 12345,
'date-last-viewed': 1580423184,
'flags': {...},
...}
>>> m.flags
{'read': True, 'answered': True, 'attachment_count': 2}