Reputation: 25628
I am currently migrating from OpenPop to MailKit.
I have a unit test that loads a string into a MimeMessage like this:
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 : <syd1_did11-1403160784-288657210-5-21314.1403160831@medora2.syd1.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);
Whilst the message is successfully parsed, the MessageId header is not found. OpenPop could find the MessageId in the email. Why does MailKit fail? Is the message id header somehow considered invalid and thrown away?
Upvotes: 1
Views: 1209
Reputation: 38538
The problem is the extra space before the ':' char:
Message-ID : <syd1_did11-1403160784-288657210-5-21314.1403160831@medora2.syd1.colo.j2noc.com>
Upvotes: 1