Chilkat 29-Dec-2021 – IMAP Server Response: BAD Command received in Invalid state
What’s going on in Chilkat support today…
1. Extremely long HTTP request headers can be a problem. (Headers that are more than 1000 characters in length) Some HTTP servers reject them unless the MIME header is folded. Some servers are OK with long headers. If folded to multiple lines, MIME headers need to fold opportunistically at whitespace. If there is no whitespace, then B-encoding is used to facilitate MIME header folding, but some servers don’t recognize the encoding.
There was a recent case where a Cookie header field was extremely long, had no whitespace, and therefore Chilkat folded the MIME header using B-encoding “=?utf-8?B?…..?=”. The server rejected it. It seems the majority of HTTP servers can’t process B-encoded folded header fields.
Chilkat has been modified to avoid folding MIME headers in this way unless the keyword “B_ENCODE_FOLD_LONG_HEADERS” is found in the UncommonOptions property.
2. IMAP Server Response: BAD Command received in Invalid state. This is a typical error if trying to authenticate with an IMAP server without TLS, but the server requires a TLS connection. For example, Hotmail accounts require TLS connections. The solution is to make sure your application connects to IMAP using TLS. The IMAP TLS port is 993.