{"record":{"id":"5febaa7263eb0dbf","repo":"jstedfast/MailKit","slug":"the-imap-server-does-not-support-the-utf8-extension","errorCode":null,"errorMessage":"The IMAP server does not support the UTF8 extension.","messagePattern":"The IMAP server does not support the UTF8 extension\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":4400,"sourceCode":"\t\t\t\tif (unmark.Count > 0) {\n\t\t\t\t\t// restore the \\Deleted flags\n\t\t\t\t\tawait StoreAsync (unmark.UniqueIds, AddDeletedFlag, cancellationToken).ConfigureAwait (false);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tforeach (var ic in Engine.QueueCommands (cancellationToken, this, \"UID EXPUNGE %s\\r\\n\", uids)) {\n\t\t\t\tawait Engine.RunAsync (ic).ConfigureAwait (false);\n\n\t\t\t\tProcessExpungeResponse (ic);\n\t\t\t}\n\t\t}\n\n\t\tFormatOptions CreateAppendOptions (FormatOptions options)\n\t\t{\n\t\t\tif (options.International && (Engine.Capabilities & ImapCapabilities.UTF8Accept) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the UTF8 extension.\");\n\n\t\t\tvar format = options.Clone ();\n\t\t\tformat.NewLineFormat = NewLineFormat.Dos;\n\t\t\tformat.EnsureNewLine = true;\n\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.UTF8Only) == ImapCapabilities.UTF8Only)\n\t\t\t\tformat.International = true;\n\n\t\t\tif (format.International && !Engine.UTF8Enabled)\n\t\t\t\tthrow new InvalidOperationException (\"The UTF8 extension has not been enabled.\");\n\n\t\t\treturn format;\n\t\t}\n\n\t\tImapCommand QueueAppendCommand (FormatOptions options, IAppendRequest request, CancellationToken cancellationToken)\n\t\t{\n\t\t\tif (options == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (options));","sourceCodeStart":4382,"sourceCodeEnd":4418,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L4382-L4418","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reusing a FormatOptions configured for an IMAP4REV1-only or older server; sending internationalized mailbox names/messages to legacy servers;误用 a globally cached FormatOptions.","solutions":["Check (client.Capabilities & ImapCapabilities.UTF8Accept) != 0 before setting options.International.","Use plain FormatOptions.Default (International = false) for servers lacking UTF8 support.","Call ImapClient.EnableUTF8() on servers that support it, then use International options.","Fallback: re-encode content without international features instead of APPENDing with UTF8."],"exampleFix":"// before\nvar options = FormatOptions.Default.Clone ();\noptions.International = true;\nfolder.Append (options, request);\n// after\nvar options = FormatOptions.Default.Clone ();\nif ((client.Capabilities & ImapCapabilities.UTF8Accept) != 0)\n    options.International = true;\nfolder.Append (options, request);","handlingStrategy":"validation","validationCode":"bool utf8Ok = (client.Capabilities & ImapCapabilities.UTF8Accept) != 0; if (!utf8Ok) options.International = false;","typeGuard":"bool SupportsUtf8 (ImapClient c) => (c.Capabilities & ImapCapabilities.UTF8Accept) != 0;","tryCatchPattern":"try { folder.Append (options, request); } catch (NotSupportedException) { options.International = false; folder.Append (options, request); }","preventionTips":["Only set FormatOptions.International after verifying UTF8Accept capability","Do not share a single International options instance across servers","Call EnableUTF8() when the server supports it and you need i18n features"],"tags":["imap","mailkit","utf8","append","not-supported"],"backgroundTag":"feature-not-enabled","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}