jstedfast/MailKit · error · NotSupportedException

The IMAP server does not support the STATUS command.

Error message

The IMAP server does not support the STATUS command.

What it means

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).

Solutions

  1. Verify capabilities with client.Capabilities after connecting; if Status flag is missing, do not call Status
  2. Fetch the needed information without STATUS: SelectFolder/Open the folder and read folder.Count/Unread etc.
  3. Use a compliant IMAP server or upgrade server firmware/software
  4. If behind a proxy, fix the proxy to pass through the CAPABILITY list

Example fix

// before
await folder.StatusAsync(StatusItems.Count | StatusItems.Unread);
// after
if ((client.Capabilities & ImapCapabilities.Status) != 0) {
    await folder.StatusAsync(StatusItems.Count | StatusItems.Unread);
} else {
    await folder.OpenAsync(FolderAccess.ReadOnly);
    var count = folder.Count;
}
Defensive patterns

Strategy: validation

Validate before calling

if ((client.Capabilities & ImapCapabilities.Status) == 0)
    throw new NotSupportedException("Server lacks STATUS; open the folder to read counts.");

Type guard

bool SupportsStatus(IMapClient c) => (c.Capabilities & ImapCapabilities.Status) != 0;

Try / catch

try {
    await folder.StatusAsync(StatusItems.Count | StatusItems.Unread);
} catch (NotSupportedException) {
    await folder.OpenAsync(FolderAccess.ReadOnly); // fallback path
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15). Data as JSON: /api/errors/24b6a22b6c707ce3. Report an issue: GitHub.

Appendix: source

Thrown at MailKit/Net/Imap/ImapFolder.cs:2127

		/// <exception cref="ImapProtocolException">
		/// The server's response contained unexpected tokens.
		/// </exception>
		/// <exception cref="ImapCommandException">
		/// The server replied with a NO or BAD response.
		/// </exception>
		public override async Task CheckAsync (CancellationToken cancellationToken = default)
		{
			var ic = QueueCheckCommand (cancellationToken);

			await Engine.RunAsync (ic).ConfigureAwait (false);

			ProcessCheckResponse (ic);
		}

		ImapCommand? QueueStatusCommand (StatusItems items, CancellationToken cancellationToken)
		{
			if ((Engine.Capabilities & ImapCapabilities.Status) == 0)
				throw new NotSupportedException ("The IMAP server does not support the STATUS command.");

			CheckState (false, false);

			if (items == StatusItems.None)
				return null;

			var command = string.Format ("STATUS %F ({0})\r\n", Engine.GetStatusQuery (items));

			return Engine.QueueCommand (cancellationToken, null, command, this);
		}

		void ProcessStatusResponse (ImapCommand ic, bool throwNotFound)
		{
			ProcessResponseCodes (ic, this, throwNotFound);

			ic.ThrowIfNotOk ("STATUS");
		}

View on GitHub (pinned to 9d3859a785)