{"record":{"id":"24b6a22b6c707ce3","repo":"jstedfast/MailKit","slug":"the-imap-server-does-not-support-the-status-command","errorCode":null,"errorMessage":"The IMAP server does not support the STATUS command.","messagePattern":"The IMAP server does not support the STATUS command\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":2127,"sourceCode":"\t\t/// <exception cref=\"ImapProtocolException\">\n\t\t/// The server's response contained unexpected tokens.\n\t\t/// </exception>\n\t\t/// <exception cref=\"ImapCommandException\">\n\t\t/// The server replied with a NO or BAD response.\n\t\t/// </exception>\n\t\tpublic override async Task CheckAsync (CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tvar ic = QueueCheckCommand (cancellationToken);\n\n\t\t\tawait Engine.RunAsync (ic).ConfigureAwait (false);\n\n\t\t\tProcessCheckResponse (ic);\n\t\t}\n\n\t\tImapCommand? QueueStatusCommand (StatusItems items, CancellationToken cancellationToken)\n\t\t{\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.Status) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the STATUS command.\");\n\n\t\t\tCheckState (false, false);\n\n\t\t\tif (items == StatusItems.None)\n\t\t\t\treturn null;\n\n\t\t\tvar command = string.Format (\"STATUS %F ({0})\\r\\n\", Engine.GetStatusQuery (items));\n\n\t\t\treturn Engine.QueueCommand (cancellationToken, null, command, this);\n\t\t}\n\n\t\tvoid ProcessStatusResponse (ImapCommand ic, bool throwNotFound)\n\t\t{\n\t\t\tProcessResponseCodes (ic, this, throwNotFound);\n\n\t\t\tic.ThrowIfNotOk (\"STATUS\");\n\t\t}\n","sourceCodeStart":2109,"sourceCodeEnd":2145,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L2109-L2145","documentation":"NotSupportedException thrown by QueueStatusCommand when the connected IMAP server did not advertise the STATUS capability (RFC 3501 STATUS is mandatory in base IMAP4rev1, so this typically means the server is a limited/pre-auth or non-compliant implementation, or STATUS was stripped).","triggerScenarios":"Calling folder.StatusAsync(items) or folder.Status(items) on a server whose ImapCapabilities lacks the Status flag; QueueStatusCommand checks (Engine.Capabilities & ImapCapabilities.Status) == 0 before CheckState.","commonSituations":"Connecting to a minimal/proxy IMAP server or a gateway (e.g. some POP/IMAP bridges) that omits STATUS; connecting over a custom protocol handler; misbehaving middleware that filters CAPABILITY responses.","solutions":["Verify capabilities with client.Capabilities after connecting; if Status flag is missing, do not call Status","Fetch the needed information without STATUS: SelectFolder/Open the folder and read folder.Count/Unread etc.","Use a compliant IMAP server or upgrade server firmware/software","If behind a proxy, fix the proxy to pass through the CAPABILITY list"],"exampleFix":"// before\nawait folder.StatusAsync(StatusItems.Count | StatusItems.Unread);\n// after\nif ((client.Capabilities & ImapCapabilities.Status) != 0) {\n    await folder.StatusAsync(StatusItems.Count | StatusItems.Unread);\n} else {\n    await folder.OpenAsync(FolderAccess.ReadOnly);\n    var count = folder.Count;\n}","handlingStrategy":"validation","validationCode":"if ((client.Capabilities & ImapCapabilities.Status) == 0)\n    throw new NotSupportedException(\"Server lacks STATUS; open the folder to read counts.\");","typeGuard":"bool SupportsStatus(IMapClient c) => (c.Capabilities & ImapCapabilities.Status) != 0;","tryCatchPattern":"try {\n    await folder.StatusAsync(StatusItems.Count | StatusItems.Unread);\n} catch (NotSupportedException) {\n    await folder.OpenAsync(FolderAccess.ReadOnly); // fallback path\n}","preventionTips":["Always inspect client.Capabilities right after Connect/Authenticate","Prefer opening the folder and reading Count/Unread when possible","Test your code against all IMAP servers you plan to support","Log capabilities at startup to diagnose server feature drift"],"tags":["imap","not-supported","capability","status"],"backgroundTag":"unsupported-operation","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}