1
我目前正在从OpenPop迁移到MailKit。MailKit找不到消息ID
我有加载一个字符串转换成一个MimeMessage这样一个单元测试:
var emailText = @"
X-MDAV-Processed: mx1.footechnology.com.au, Mon, 30 Mar 2015 12:54:30 +1100
Return-path: <[email protected]>
Received: from mail2.baz.com.au (mail2.baz.com.au [220.157.74.146])
by mx1.footechnology.com.au (mx1.footechnology.com.au)
(MDaemon PRO v11.0.3)
with ESMTP id md50005410292.msg
for <[email protected]>; Mon, 30 Mar 2015 12:54:29 +1100
Authentication-Results: mx1.footechnology.com.au
spf=neutral [email protected];
x-ip-ptr=pass dns.ptr=mail2.baz.com.au (ip=220.157.74.146);
x-ip-helo=pass smtp.helo=mail2.baz.com.au (ip=220.157.74.146);
x-ip-mail=pass [email protected] (ip=220.157.74.146)
Received-SPF: none (mx1.footechnology.com.au: [email protected] does not
designate permitted sender hosts)
x-spf-client=MDaemon.PRO.v11.0.3
receiver=mx1.footechnology.com.au
client-ip=220.157.74.146
envelope-from=<[email protected]>
helo=mail2.baz.com.au
X-Spam-Processed: mx1.footechnology.com.au, Mon, 30 Mar 2015 12:54:29 +1100
(not processed: sender [email protected] in exclude file)
X-MDPtrLookup-Result: pass dns.ptr=mail2.baz.com.au (ip=220.157.74.146) (mx1.footechnology.com.au)
X-MDHeloLookup-Result: pass smtp.helo=mail2.baz.com.au (ip=220.157.74.146) (mx1.footechnology.com.au)
X-MDMailLookup-Result: pass [email protected] (ip=220.157.74.146) (mx1.footechnology.com.au)
X-MDDK-Result: neutral (mx1.footechnology.com.au)
X-MDDKIM-Result: neutral (mx1.footechnology.com.au)
X-MDSPF-Result: none (mx1.footechnology.com.au)
X-Rcpt-To: [email protected]
X-MDRcpt-To: [email protected]
X-MDRemoteIP: 220.157.74.146
X-Return-Path: [email protected]
X-Envelope-From: [email protected]
X-MDaemon-Deliver-To: [email protected]
Received: from melbourne.baz.com.au (melbourne.baz.com.au [118.88.188.238])
by mail2.baz.com.au (Postfix) with ESMTP id 3E100437181
for <[email protected]>; Mon, 30 Mar 2015 11:54:17 +1000 (EST)
Received: from baz.com.au (localhost [127.0.0.1])
by melbourne.baz.com.au (Postfix) with ESMTP id 6BA057C07C
for <[email protected]>; Mon, 30 Mar 2015 12:54:16 +1100 (EST)
Content-Transfer-Encoding: binary
Message-ID : <[email protected]colo.j2noc.com>
Content-Type: multipart/mixed; boundary=""_----------=_1301450056175850""
MIME-Version: 1.0
X-Mailer: MIME::Lite 3.01 (F2.72; B3.04; Q3.03)
Date: Mon, 30 Mar 2015 01:54:16 UT
From: ""Baz"" <[email protected]>
To: ""Foo Bar"" <[email protected]>
This is a multi-part message in MIME format.
--_----------=_1301450056175850
Content-Disposition: inline
Content-Length: 1133
Content-Transfer-Encoding: binary
Content-Type: text/plain
This is the content of the message.
--_----------=_1301450056175850
Content-Disposition: attachment; filename=""fax-20110330125416.pdf""
Content-Transfer-Encoding: base64
Content-Type: application/pdf; name=""fax-20110330125416.pdf""
JVBERi0xLjEgDSXi48/TDQoxIDAgb2JqDTw8IA0vVHlwZSAvQ2F0YWxvZyAN
--_----------=_1301450056175850--
";
var stream = new MemoryStream(Encoding.UTF8.GetBytes(emailText));
var message = MimeMessage.Load(stream);
Console.WriteLine("Text body:" + message.TextBody);
Console.WriteLine("Html body:" + message.HtmlBody);
Console.WriteLine("Date:" + message.Date);
Console.WriteLine("MessageId:" + message.MessageId);
Console.WriteLine("From:" + message.From.Mailboxes.First().Address);
Console.WriteLine("To:" + message.To.Mailboxes.First().Address);
虽然该消息被成功地分析,邮件ID报头中没有找到。 OpenPop可以在电子邮件中找到MessageId。为什么MailKit失败?消息ID标头是否被认为无效并被丢弃?
感谢jstedfast。对不起,一旦你指出,这一点很清楚...... – cbp 2015-02-11 01:07:22
我刚刚[提交修复](https://github.com/jstedfast/MimeKit/commit/12d31d9c5c695f69734a14e607c88d50978a6e91)到MimeKit来处理字段名称后的空格,所以下一个版本的MimeKit(1.0.10?)将会处理这个问题。 – jstedfast 2015-03-10 14:39:02