jstedfast/MailKit · error · NotSupportedException

The IMAP server does not support the QUOTA extension.

Error message

The IMAP server does not support the QUOTA extension.

What it means

GetQuota (and related quota APIs) depends on the IMAP QUOTA extension (RFC 2087/9208). MailKit checks ImapCapabilities.Quota before queueing GETQUOTAROOT and throws NotSupportedException when the server did not advertise it, as it cannot report storage usage/limits.

Solutions

  1. Check (client.Capabilities & ImapCapabilities.Quota) != 0 before calling quota APIs
  2. Obtain storage info from the provider's native API instead (e.g. Gmail API about/getStorageQuota)
  3. Switch to an IMAP server that supports the QUOTA extension if IMAP-based quota is required
  4. Catch NotSupportedException and hide/disable quota UI when unsupported

Example fix

// before
var quota = folder.GetQuota();
// after
if ((client.Capabilities & ImapCapabilities.Quota) != 0)
    var quota = folder.GetQuota();
else
    var quota = null; // server does not report quota over IMAP
Defensive patterns

Strategy: validation

Validate before calling

if ((client.Capabilities & ImapCapabilities.Quota) == 0)
    throw new NotSupportedException("Server does not support IMAP QUOTA");

Type guard

bool SupportsQuota(ImapClient c) => (c.Capabilities & ImapCapabilities.Quota) != 0;

Try / catch

try {
    var quota = folder.GetQuota();
} catch (NotSupportedException ex) {
    logger.LogInformation(ex, "QUOTA unsupported; storage usage unavailable via IMAP");
    var quota = null;
}

Prevention

When it happens

Trigger: Calling ImapFolder.GetQuota or ImapFolder.GetQuotaRoot on a server whose CAPABILITY response lacks QUOTA.

Common situations: Showing mailbox storage usage in an app connected to Gmail (which does not advertise IMAP QUOTA) or other consumer providers; expecting quota info on servers that expose it only via web APIs.

Related errors


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

Appendix: source

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

		/// <param name="ic">The IMAP command.</param>
		/// <param name="index">The index.</param>
		/// <param name="doAsync">Whether or not asynchronous IO methods should be used.</param>
		static Task UntaggedQuotaHandler (ImapEngine engine, ImapCommand ic, int index, bool doAsync)
		{
			if (doAsync)
				return ParseQuotaAsync (engine, ic);

			ParseQuota (engine, ic);

			return Task.CompletedTask;
		}

		ImapCommand QueueGetQuotaCommand (CancellationToken cancellationToken)
		{
			CheckState (false, false);

			if ((Engine.Capabilities & ImapCapabilities.Quota) == 0)
				throw new NotSupportedException ("The IMAP server does not support the QUOTA extension.");

			var ic = new ImapCommand (Engine, cancellationToken, null, "GETQUOTAROOT %F\r\n", this);
			var ctx = new QuotaContext ();

			ic.RegisterUntaggedHandler ("QUOTAROOT", UntaggedQuotaRootHandler);
			ic.RegisterUntaggedHandler ("QUOTA", UntaggedQuotaHandler);
			ic.UserData = ctx;

			Engine.QueueCommand (ic);

			return ic;
		}

		bool TryProcessGetQuotaResponse (ImapCommand ic, [NotNullWhen (true)] out string? encodedName, [NotNullWhen (true)] out Quota? quota)
		{
			var ctx = (QuotaContext) ic.UserData!;

			ProcessResponseCodes (ic, null);

View on GitHub (pinned to 9d3859a785)