Skip to content

Empty headers malformated when encoding #58

Closed
@joelsand

Description

Hi there,

It appears that if the From or To headers don't have any entries, they are missing a line-feed after it is serialized. For example:

From: Test User <test@example.com>
To:Date: Thu, 26 Jun 2014 08:42:48 -0500
Subject: This is the subject
Message-Id: <aa9ab005-29e8-9ca2-0a0a-a1f3b8667d05@example>
Cc: Test User <test@example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8

This is the body.

was generated by the code

MimeMessage message = new MimeMessage();
message.Date = DateTime.Now;
message.Subject = "This is the subject";
message.From.Add(new MailboxAddress("Test User", "test@example.com"));
message.Cc.Add(new MailboxAddress("Test User", "test@example.com"));

message.Body = new TextPart() { Text = "This is the body." };

using (MemoryStream ms = new MemoryStream())
{
    message.WriteTo(ms);

    string mimeEncoded = Encoding.ASCII.GetString(ms.ToArray());
    Console.WriteLine(mimeEncoded);
}

Parsing has been working great, though!

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions