jstedfast/MailKit · error · NotSupportedException

The IMAP server does not support the UTF8=ACCEPT extension.

Error message

The IMAP server does not support the UTF8=ACCEPT extension.

What it means

MailKit throws this NotSupportedException when EnableUTF8 is called but the server's CAPABILITY response did not include UTF8=ACCEPT (ImapCapabilities.UTF8Accept). The RFC 6855 extension must be advertised by the server; the client cannot enable it unilaterally.

Solutions

  1. Check (client.Capabilities & ImapCapabilities.UTF8Accept) != 0 before calling EnableUTF8
  2. Fall back to modified-UTF7 mailbox naming (ImapFolder encoding handles this automatically) when unsupported
  3. Enable RFC 6855 support on the server if internationalized mailbox names/headers are required

Example fix

// before
client.EnableUTF8 ();
// after
if ((client.Capabilities & ImapCapabilities.UTF8Accept) != 0)
    client.EnableUTF8 ();
Defensive patterns

Strategy: fallback

Validate before calling

if ((client.Capabilities & ImapCapabilities.UTF8Accept) == 0) return; // use modified-UTF7 names instead

Type guard

bool SupportsUtf8Accept (ImapClient c) => (c.Capabilities & ImapCapabilities.UTF8Accept) != 0;

Try / catch

try { client.EnableUTF8 (); } catch (NotSupportedException) { /* fall back to modified UTF-7 mailbox names */ }

Prevention

When it happens

Trigger: Calling EnableUTF8() while (engine.Capabilities & ImapCapabilities.UTF8Accept) == 0 — the server did not advertise UTF8=ACCEPT.

Common situations: Connecting to servers without RFC 6855 support (older Dovecot/Courier configs); calling EnableUTF8 unconditionally in cross-server code; expecting UTF8 mailbox names to work on legacy servers.

Related errors


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

Appendix: source

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

			if (!TryQueueEnableQuickResyncCommand (cancellationToken, out var ic))
				return;

			engine.Run (ic);

			ProcessEnableResponse (ic);
		}

		bool TryQueueEnableUTF8Command (CancellationToken cancellationToken, [NotNullWhen (true)] out ImapCommand? ic)
		{
			CheckDisposed ();
			CheckConnected ();
			CheckAuthenticated ();

			if (engine.State != ImapEngineState.Authenticated)
				throw new InvalidOperationException ("UTF8=ACCEPT needs to be enabled immediately after authenticating.");

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

			if (engine.UTF8Enabled) {
				ic = null;
				return false;
			}

			ic = engine.QueueCommand (cancellationToken, null, "ENABLE UTF8=ACCEPT\r\n");

			return true;
		}

		/// <summary>
		/// Enable the UTF8=ACCEPT extension.
		/// </summary>
		/// <remarks>
		/// Enables the <a href="https://tools.ietf.org/html/rfc6855">UTF8=ACCEPT</a> extension.
		/// </remarks>
		/// <param name="cancellationToken">The cancellation token.</param>

View on GitHub (pinned to 9d3859a785)