{"record":{"id":"14d44cd8fae075bc","repo":"jstedfast/MailKit","slug":"the-imap-server-does-not-support-the-notify-extension","errorCode":null,"errorMessage":"The IMAP server does not support the NOTIFY extension.","messagePattern":"The IMAP server does not support the NOTIFY extension\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapClient.cs","lineNumber":2025,"sourceCode":"\n\t\t\t\tProcessIdleResponse (ic);\n\t\t\t}\n\t\t}\n\n\t\tImapCommand QueueNotifyCommand (bool status, IList<ImapEventGroup> eventGroups, CancellationToken cancellationToken, out bool notifySelectedNewExpunge)\n\t\t{\n\t\t\tif (eventGroups == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (eventGroups));\n\n\t\t\tif (eventGroups.Count == 0)\n\t\t\t\tthrow new ArgumentException (\"No event groups specified.\", nameof (eventGroups));\n\n\t\t\tCheckDisposed ();\n\t\t\tCheckConnected ();\n\t\t\tCheckAuthenticated ();\n\n\t\t\tif ((engine.Capabilities & ImapCapabilities.Notify) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the NOTIFY extension.\");\n\n\t\t\tnotifySelectedNewExpunge = false;\n\n\t\t\tvar command = new StringBuilder (\"NOTIFY SET\");\n\t\t\tvar args = new List<object> ();\n\n\t\t\tif (status)\n\t\t\t\tcommand.Append (\" STATUS\");\n\n\t\t\tforeach (var group in eventGroups) {\n\t\t\t\tcommand.Append (' ');\n\n\t\t\t\tgroup.Format (engine, command, args, ref notifySelectedNewExpunge);\n\t\t\t}\n\n\t\t\tcommand.Append (\"\\r\\n\");\n\n\t\t\tvar ic = new ImapCommand (engine, cancellationToken, null, command.ToString (), args.ToArray ());","sourceCodeStart":2007,"sourceCodeEnd":2043,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapClient.cs#L2007-L2043","documentation":"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.","triggerScenarios":"Calling SetNotifyAsync against a server not advertising NOTIFY; enabling notify unconditionally in push-notification code paths.","commonSituations":"Most public IMAP servers (Gmail, common hosting) do not support NOTIFY; code written for a QRESYNC/NOTIFY-capable server deployed against a standard one.","solutions":["Check (client.Capabilities & ImapCapabilities.Notify) != 0 before calling SetNotifyAsync","Fall back to IDLE-based notifications when NOTIFY is unavailable","Fall back to periodic NOOP polling as a last resort"],"exampleFix":"// before\nawait client.SetNotifyAsync(groups, token);\n// after\nif ((client.Capabilities & ImapCapabilities.Notify) != 0)\n    await client.SetNotifyAsync(groups, token);\nelse\n    await StartIdleAsync(client, token);","handlingStrategy":"fallback","validationCode":"bool canNotify = (client.Capabilities & ImapCapabilities.Notify) != 0;","typeGuard":null,"tryCatchPattern":"try { await client.SetNotifyAsync(groups, token); }\ncatch (NotSupportedException) { await StartIdleAsync(client, token); }","preventionTips":["Assume NOTIFY is rare; prefer IDLE-first push strategies","Feature-detect capabilities once after authentication","Log server capabilities at connect time to debug env differences"],"tags":["imap","notify","capability","mailkit"],"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-15T23:17:13.987Z"}