jstedfast/MailKit · error · NotSupportedException

The IMAP server does not support the NOTIFY extension.

Error message

The IMAP server does not support the NOTIFY extension.

What it means

Capability check in QueueNotifyCommand: after disposing/connecting/authenticating, the code verifies the server advertised the NOTIFY capability (IMAP NOTIFY extension, RFC 5465). Requesting event groups against a server without NOTIFY support is unsupported, so NotSupportedException is thrown. This is a sentinel guard on server capability, not on caller input.

Solutions

  1. Check (client.Capabilities & ImapCapabilities.Notify) != 0 before calling SetNotifyAsync
  2. Fall back to IDLE-based notifications when NOTIFY is unavailable
  3. Fall back to periodic NOOP polling as a last resort

Example fix

// before
await client.SetNotifyAsync(groups, token);
// after
if ((client.Capabilities & ImapCapabilities.Notify) != 0)
    await client.SetNotifyAsync(groups, token);
else
    await StartIdleAsync(client, token);
Defensive patterns

Strategy: fallback

Validate before calling

bool canNotify = (client.Capabilities & ImapCapabilities.Notify) != 0;

Try / catch

try { await client.SetNotifyAsync(groups, token); }
catch (NotSupportedException) { await StartIdleAsync(client, token); }

Prevention

When it happens

Trigger: Calling SetNotifyAsync against a server not advertising NOTIFY; enabling notify unconditionally in push-notification code paths.

Common situations: Most public IMAP servers (Gmail, common hosting) do not support NOTIFY; code written for a QRESYNC/NOTIFY-capable server deployed against a standard one.

Related errors


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

Appendix: source

Thrown at MailKit/Net/Imap/ImapClient.cs:2025

				ProcessIdleResponse (ic);
			}
		}

		ImapCommand QueueNotifyCommand (bool status, IList<ImapEventGroup> eventGroups, CancellationToken cancellationToken, out bool notifySelectedNewExpunge)
		{
			if (eventGroups == null)
				throw new ArgumentNullException (nameof (eventGroups));

			if (eventGroups.Count == 0)
				throw new ArgumentException ("No event groups specified.", nameof (eventGroups));

			CheckDisposed ();
			CheckConnected ();
			CheckAuthenticated ();

			if ((engine.Capabilities & ImapCapabilities.Notify) == 0)
				throw new NotSupportedException ("The IMAP server does not support the NOTIFY extension.");

			notifySelectedNewExpunge = false;

			var command = new StringBuilder ("NOTIFY SET");
			var args = new List<object> ();

			if (status)
				command.Append (" STATUS");

			foreach (var group in eventGroups) {
				command.Append (' ');

				group.Format (engine, command, args, ref notifySelectedNewExpunge);
			}

			command.Append ("\r\n");

			var ic = new ImapCommand (engine, cancellationToken, null, command.ToString (), args.ToArray ());

View on GitHub (pinned to 9d3859a785)