jstedfast/MailKit · error · NotSupportedException

The IMAP server does not support the UTF8 extension.

Error message

The IMAP server does not support the UTF8 extension.

What it means

CreateAppendOptions is used by Append/AppendAsync: when FormatOptions.International is set (UTF8 encoding requested), the IMAP server must advertise UTF8=ACCEPT. If the UTF8Accept capability is missing, a NotSupportedException is thrown because the server cannot handle the internationalized APPEND.

Solutions

  1. Check (client.Capabilities & ImapCapabilities.UTF8Accept) != 0 before setting options.International.
  2. Use plain FormatOptions.Default (International = false) for servers lacking UTF8 support.
  3. Call ImapClient.EnableUTF8() on servers that support it, then use International options.
  4. Fallback: re-encode content without international features instead of APPENDing with UTF8.

Example fix

// before
var options = FormatOptions.Default.Clone ();
options.International = true;
folder.Append (options, request);
// after
var options = FormatOptions.Default.Clone ();
if ((client.Capabilities & ImapCapabilities.UTF8Accept) != 0)
    options.International = true;
folder.Append (options, request);
Defensive patterns

Strategy: validation

Validate before calling

bool utf8Ok = (client.Capabilities & ImapCapabilities.UTF8Accept) != 0; if (!utf8Ok) options.International = false;

Type guard

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

Try / catch

try { folder.Append (options, request); } catch (NotSupportedException) { options.International = false; folder.Append (options, request); }

Prevention

When it happens

Trigger: Calling Append/AppendAsync with FormatOptions where International == true (e.g. options.International = true, or a shared options instance created elsewhere) against a server without UTF8=ACCEPT.

Common situations: Reusing a FormatOptions configured for an IMAP4REV1-only or older server; sending internationalized mailbox names/messages to legacy servers;误用 a globally cached FormatOptions.

Related errors


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

Appendix: source

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

				if (unmark.Count > 0) {
					// restore the \Deleted flags
					await StoreAsync (unmark.UniqueIds, AddDeletedFlag, cancellationToken).ConfigureAwait (false);
				}

				return;
			}

			foreach (var ic in Engine.QueueCommands (cancellationToken, this, "UID EXPUNGE %s\r\n", uids)) {
				await Engine.RunAsync (ic).ConfigureAwait (false);

				ProcessExpungeResponse (ic);
			}
		}

		FormatOptions CreateAppendOptions (FormatOptions options)
		{
			if (options.International && (Engine.Capabilities & ImapCapabilities.UTF8Accept) == 0)
				throw new NotSupportedException ("The IMAP server does not support the UTF8 extension.");

			var format = options.Clone ();
			format.NewLineFormat = NewLineFormat.Dos;
			format.EnsureNewLine = true;

			if ((Engine.Capabilities & ImapCapabilities.UTF8Only) == ImapCapabilities.UTF8Only)
				format.International = true;

			if (format.International && !Engine.UTF8Enabled)
				throw new InvalidOperationException ("The UTF8 extension has not been enabled.");

			return format;
		}

		ImapCommand QueueAppendCommand (FormatOptions options, IAppendRequest request, CancellationToken cancellationToken)
		{
			if (options == null)
				throw new ArgumentNullException (nameof (options));

View on GitHub (pinned to 9d3859a785)