{"record":{"id":"214f6b1e026d3abe","repo":"jstedfast/MailKit","slug":"the-imap-server-does-not-support-the-compress-extension","errorCode":null,"errorMessage":"The IMAP server does not support the COMPRESS extension.","messagePattern":"The IMAP server does not support the COMPRESS extension\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapClient.cs","lineNumber":292,"sourceCode":"\t\t\t} else {\n\t\t\t\tvalid = DefaultServerCertificateValidationCallback (host, certificate, chain, sslPolicyErrors);\n\t\t\t}\n\n\t\t\tif (!valid) {\n\t\t\t\t// Note: The SslHandshakeException.Create() method will nullify this once it's done using it.\n\t\t\t\tsslValidationInfo = new SslCertificateValidationInfo (host, certificate, chain, sslPolicyErrors);\n\t\t\t}\n\n\t\t\treturn valid;\n\t\t}\n\n\t\tImapCommand QueueCompressCommand (CancellationToken cancellationToken)\n\t\t{\n\t\t\tCheckDisposed ();\n\t\t\tCheckConnected ();\n\n\t\t\tif ((engine.Capabilities & ImapCapabilities.Compress) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the COMPRESS extension.\");\n\n\t\t\tif (engine.State >= ImapEngineState.Selected)\n\t\t\t\tthrow new InvalidOperationException (\"Compression must be enabled before selecting a folder.\");\n\n#if MAILKIT_LITE\n\t\t\tthrow new NotSupportedException (\"MailKitLite does not support the COMPRESS extension.\");\n#else\n\t\t\treturn engine.QueueCommand (cancellationToken, null, \"COMPRESS DEFLATE\\r\\n\");\n#endif\n\t\t}\n\n\t\tvoid ProcessCompressResponse (ImapCommand ic)\n\t\t{\n#if !MAILKIT_LITE\n\t\t\tif (ic.Response != ImapCommandResponse.Ok) {\n\t\t\t\tfor (int i = 0; i < ic.RespCodes.Count; i++) {\n\t\t\t\t\tif (ic.RespCodes[i].Type == ImapResponseCodeType.CompressionActive)\n\t\t\t\t\t\treturn;","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapClient.cs#L274-L310","documentation":"Before sending the COMPRESS DEFLATE command, ImapClient checks the server's advertised CAPABILITIES for ImapCapabilities.Compress. If the server does not advertise COMPRESS=DEFLATE, the extension cannot be used and a NotSupportedException is thrown.","triggerScenarios":"Calling ImapClient.Compress(cancellationToken) on a server whose CAPABILITIES response lacks COMPRESS=DEFLATE — common with hosted/cloud IMAP providers and Exchange.","commonSituations":"Enabling compression unconditionally for performance against a provider that doesn't support it; server config change removed the extension; testing against a local server without the deflate plugin (e.g. Dovecot without imap_zlib).","solutions":["Check (client.Capabilities & ImapCapabilities.Compress) != 0 before calling Compress and skip gracefully otherwise","Enable COMPRESS support on the server (e.g. Dovecot's zlib plugin) if you control it","Use a catch of NotSupportedException to degrade gracefully to uncompressed operation"],"exampleFix":"// before\nclient.Compress(); // throws on servers without COMPRESS\n// after\nif ((client.Capabilities & ImapCapabilities.Compress) != 0)\n\tclient.Compress();","handlingStrategy":"fallback","validationCode":"bool canCompress = (client.Capabilities & ImapCapabilities.Compress) != 0;","typeGuard":"bool SupportsCompress(IMapClient c) => (c.Capabilities & ImapCapabilities.Compress) != 0;","tryCatchPattern":"try {\n\tclient.Compress();\n} catch (NotSupportedException) {\n\t// proceed uncompressed\n}","preventionTips":["Check Capabilities for ImapCapabilities.Compress before enabling compression","Know your provider's extension support (Exchange/hosted IMAP typically lack COMPRESS)","Enable the server-side zlib/deflate plugin if you control the server"],"tags":["imap","compression","unsupported-feature","capability"],"backgroundTag":"operation-not-supported","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}