[Exchange-Online][IMAP]Strange behavior from IMAP server RRS feed

  • Question

  • I am trying to send a message to Office 365 via IMAP (using my own software).  What I am seeing is, if the message is over a certain size (10240 bytes, to be exact) the server will fail to the APPEND command like this:

    Delivered-To: BAD Command Error. 10

    The server name is "".  Using SSL on port 993.

    The "Delivered-To:" happens to be the first line of the message (although there is additional text after that, it does not show up in the error message).  For some reason it thinks that the first line of data is a command, instead of message text.  If the total length of the message is less than 10240, then it works just fine (with the exact same data, just cutoff at the end).  For example, here is the first part of the trace, where it fails:

    <send 67>A009 APPEND "Migrated/INBOX" "08-May-2013 13:38:56 -0800" {21748}
    <recv 38>+ Ready for additional command text.
    <send 21748>Delivered-To:
    Received: by with SMTP id yd1csp6294wjb;
            Wed, 8 May 2013 08:38:58 -0700 (PDT)

    (the <send> and <recv> strings are not part of the data, just info from the trace).  Here is a trace where it works:

    <send 67>A009 APPEND "Migrated/INBOX" "08-May-2013 13:38:56 -0800" {8000}
    <recv 38>+ Ready for additional command text.
    <send 8000>Delivered-To:
    Received: by with SMTP id yd1csp6294wjb;
            Wed, 8 May 2013 08:38:58 -0700 (PDT)

    In this case, I have arbitrarily cut off the data at 8000 bytes. The APPEND command works fine. 

    By the way, this exact same code/data works fine with every other IMAP server I have tried.  Any ideas?

    • Edited by Jeff McKay Thursday, November 28, 2013 12:33 AM
    Thursday, November 28, 2013 12:29 AM

All replies

  • Hi Jeff

    I ran into the exact same issue (using javax.mail). Did you ever find a solution or a work-around for this problem?

    Thanks and cheers


    Monday, May 22, 2017 7:29 AM
  • Just in case somebody else runs into this, I try to discribe the cause of our issue and how we resolved it.

    We have a java application using javax.mail to create a MimeMessage with a Multipart Message Body containing a plain text mail body and two binary attachments. The content of each of those parts is provided by a different application.

    Our java application instantiates the BodyParts for the attachments as PreencodedMimeBodyPart consuming base64 encoded message content (via ByteArrayDataSource as DataSource).

    Now the problem was that the external application did the encoding using a plain base64 algorithm instead of Mime-base64 which breaks down the data stream into lines of 76 characters per line.

    This resulted in a single over-long line for the whole attachment. Even though our former on-site exchange server had accepted this for years, Office365 does not (rightfully, I guess).

    Once we changed the encoding to Mime-base64, the mails could be stored via imap (folder.appendMessage) without problems.

    Hope this helps

    Monday, May 22, 2017 9:53 AM