NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet, #182 most downloaded on NuGet
MimeKit is an Open Source library for creating and parsing MIME, S/MIME and PGP messages on desktop and mobile platforms. It also supports parsing of Unix mbox files. As of v5.0, MimeKit is a meta-package that references both MimeKit.Core (MIME creation and parsing) and MimeKit.Cryptography (OpenPGP, S/MIME, DKIM, ARC and DMARC support). This preserves backwards compatibility for consumers that expect cryptography support out of the box. If you do not need cryptography, reference MimeKit.Core directly instead. API documentation can be found on the web at http://www.mimekit.net/docs For those that need SMTP, POP3 or IMAP support, check out https://github.com/jstedfast/MailKit
Latest stable
5.0.0
Last release 12 days ago
10 Nov 2026
Ships fairly regularly
a new release about every 6 weeks
Nearly every release is documented
notes for 58 of the last 60 stable releases
115 versions withdrawn
withdrawn after publishing
127 years old
200 releases · first in 1900
Drag across the ruler to compare, or tap a release to open it.
MimeKit 5.0 is a major release containing a number of breaking changes. See https://github.com/jstedfast/MimeKit/blob/master/ReleaseNotes.md for the c…
MimeKit 5.0 is a major release containing a number of breaking changes. See https://github.com/jstedfast/MimeKit/blob/master/ReleaseNotes.md for the complete list of changes and migration notes.
MimeKit 5.0 is a major release containing a number of breaking changes. The headline changes are the split of the cryptography support into its own assembly, the promotion of the new MIME parser, a redesigned TNEF implementation, DMARC validation, and a new MIME compliance violation reporting API. These notes describe changes since MimeKit 4.18.1. See the Porting Guide for help migrating from MimeKit 4.x.
ContentType constructors and the MediaType/MediaSubtype setters now require nonempty
ASCII MIME tokens. DomainList construction and mutation reject null elements, empty domains
and invalid domain syntax; internationalized domains, single-label names and domain literals
remain supported. Invalid values throw ArgumentException instead of being stored or silently
omitted during serialization. Parsing and cloning retain their existing recovery behavior.persistent boolean in MimeParser, IMimeParser.SetStream and
MimeMessage/MimeEntity stream Load and LoadAsync APIs with MimeContentStorage.
Memory (0) is the default and copies part content; Source (1) references the caller-owned
input stream, which must remain open and unchanged while the content is used. Source rejects
nonseekable streams with ArgumentException instead of silently copying.
LegacyMimeParser retains its public boolean APIs.MimePart.FileName and Multipart.Boundary preserve their parameter values without trimming.
InternetAddress.Name trims leading and trailing ASCII whitespace when set, including through
constructors and parsing; a name such as " John Smith " becomes "John Smith".ContentEncoding.Default to ContentEncoding.Unspecified. Its numeric value remains
zero and its behavior is unchanged: no explicit transfer encoding is selected.MimeTypes.GetMimeType now returns application/gzip for .gz/.gzip, audio/flac for
.flac, video/matroska for .mkv, and model/stl for .stl. The previous MIME names
remain supported by TryGetExtension.MimeTypes now uses registered names for PKCS#12, Debian packages, Dart, DWG/DXF, EOT,
BinHex, FrameMaker MIF, PCL, SMIL, STEP, Visio, WordPerfect, legacy Excel and troff files.
Ogg Opus files now use audio/ogg. AIFF, AVI, AU, ASF playlists, Java class files, M3U,
portable anymaps, XPM, VRML and scriptlets also use corrected mappings. Previous MIME names
remain accepted by TryGetExtension; its preferred extensions for image/x-xpixmap and
model/vrml are now .xpm and .wrl, respectively.MimeKit.IO.BoundStream to MimeKit.IO.BoundedStream. Constructor parameters and
stream behavior are unchanged; the old type name is no longer available.MimeKit.Encodings.YEncoder and YDecoder to YEncEncoder and YEncDecoder.
Update references to the new names; the low-level checksum representation is unchanged.IMimeDecoder now requires Flush (byte[], int, int, byte[]) to finalize buffered input.
The public pointer-based Decode overloads have been removed. DecoderFilter finalizes
automatically; direct callers should flush at EOF and reset before decoding another stream.
Finalization recovers complete bytes from partial base64/uuencode groups and preserves
incomplete quoted-printable/percent escapes literally instead of dropping them.Base64Encoder, QuotedPrintableEncoder, UUEncoder, YEncEncoder and EncoderFilter.Create
now default to CRLF line endings. New overloads accept NewLineFormat.Dos or
NewLineFormat.Unix; Mixed is rejected. Specify Unix to retain the previous LF output.
MIME serialization still follows FormatOptions.NewLineFormat, without a separate newline
conversion filter when freshly encoding base64, quoted-printable or uuencoded content.OpenPgpContext.AllowUnauthenticatedDecryption to true
only when legacy compatibility is required. Stream output must not be used until decryption
completes successfully.TemporarySecureMimeContext no longer trusts self-signed certificates merely because they were
imported, including certificates supplied by signed messages or PKCS#12 files. Configure trust
explicitly with Import (certificate, trusted: true) or its async counterpart.SecureMimeContext.MaxDecompressedSize (also on ISecureMimeContext) to change the limit;
oversized content throws FormatException.MimeKit.Cryptography assembly and
NuGet package. (issue #820)
MimeKit package is now a meta-package that references both MimeKit.Core and
MimeKit.Cryptography, so projects referencing MimeKit continue to get everything. Projects
that do not need S/MIME, PGP/MIME, DKIM or ARC can reference MimeKit.Core on its own.MimeKit project is now named MimeKit.Core. The MimeKit
namespace is unchanged.MimeKitLite has been retired. MimeKit.Core replaces it.MimeKit.Cryptography should call CryptographyModule.Initialize () during
startup to register the cryptographic entity factory. Without it, multipart/signed and
multipart/encrypted content will be parsed as a plain Multipart. This happens automatically
the first time CryptographyContext is used (for example, by CryptographyContext.Register ()),
but messages parsed before then will not contain any cryptographic MIME entities.MimeMessage.Sign (), Encrypt () and SignAndEncrypt () methods (and their async
counterparts) are now extension methods in MimeKit.Cryptography. Add a
using MimeKit.Cryptography; directive to continue using them.VisitApplicationPgpEncrypted (), VisitApplicationPgpSignature (),
VisitApplicationPkcs7Mime (), VisitApplicationPkcs7Signature (), VisitMultipartEncrypted ()
and VisitMultipartSigned () methods have moved from MimeVisitor to the new
CryptographicMimeVisitor class in MimeKit.Cryptography. Visitors that override any of these
methods must now derive from CryptographicMimeVisitor. A visitor that derives from MimeVisitor
will visit these entities via VisitMultipart () or VisitMimePart () instead.ExperimentalMimeParser has been renamed to MimeParser.MimeParser implementation has been renamed to LegacyMimeParser and is retained
for compatibility.MessageDeliveryStatus now uses the new parser and is no longer tied to LegacyMimeParser.ExperimentalMimeParser, the new MimeParser uses a MimeReader internally instead of
inheriting from it. Use its Parse* methods, not MimeReader.ReadHeaders (), ReadEntity () or
ReadMessage (). It exposes Options, IsEndOfStream, Position, ComplianceLogger and
ComplianceOptions, and mirrors the reader's On* callbacks as protected virtual methods.
Subclasses overriding these callbacks must call the base implementation.CryptographyContext no longer registers a default S/MIME implementation. Applications must now
explicitly register the context they want (for example via CryptographyContext.Register ()).
This change is what makes MimeKit AOT-compatible; the DefaultSecureMimeContext constructors that
rely on reflection to load a platform-appropriate SQLite library remain available for applications
that do not need AOT compatibility.DbConnection parameter from protected X509CertificateDatabase and
SqlCertificateDatabase APIs
(GetSelectCommand, GetSelectAllCrlsCommand, GetInsertCommand, GetUpdateCommand,
GetDeleteCommand, GetTableColumns, CreateTable, AddTableColumn, CreateIndex and
RemoveIndex). Subclasses must update their overrides. The constructors still take a DbConnection.beginOffset and lineNumber arguments from MimeReader.OnMboxMarkerRead () and
OnMboxMarkerReadAsync (). Both values are already supplied by the corresponding
OnMboxMarkerBegin () call, which makes the signature consistent with OnMimePartContentRead ().QEncoder class and the public HexEncoder and HexDecoder implementations.HtmlToHtml.FilterHtml property. Use a dedicated library such as HtmlSanitizer instead.IX509CertificateDatabase APIs.DkimSigner and ArcSigner APIs, including the protected DkimSignerBase.PrivateKey
setter. Subclasses must now pass the private key to the base class constructor instead.MimeReader APIs.TnefPropertyTag.Puid. Use TnefPropertyTag.PuidA or TnefPropertyTag.PuidW.partials parameter of MessagePartial.Join () from IEnumerable<MessagePartial> to
IReadOnlyList<MessagePartial>. Arrays and List<MessagePartial> continue to work unchanged.
Join () now also validates the id and number parameters of every partial up front, so a
mismatched id or missing number throws InvalidOperationException even when only a single partial
is provided.AsymmetricAlgorithmExtensions.AsAsymmetricAlgorithm () extension methods that converted
BouncyCastle AsymmetricKeyParameter and AsymmetricCipherKeyPair keys into
System.Security.Cryptography RSA, DSA and ECDsa instances. MimeKit no longer uses them.
The AsAsymmetricKeyParameter () and AsAsymmetricCipherKeyPair () conversions in the other
direction are unchanged.[Serializable], the protected
(SerializationInfo, StreamingContext) constructors and the GetObjectData () overrides) from
ParseException, TnefException, CertificateNotFoundException, DigitalSignatureVerifyException,
PrivateKeyNotFoundException and PublicKeyNotFoundException. It was only available on .NET
Framework, and the APIs it is built on have been
obsolete since .NET 8.
Microsoft considers BinaryFormatter deserialization a security vulnerability that
cannot be made secure,
even for data believed to be trustworthy, and it always throws starting with .NET 9.MimeMessage.Sign (), SignAsync (), SignAndEncrypt () and SignAndEncryptAsync ()
extension method overloads that do not take a DigestAlgorithm now sign using SHA-256 instead of
SHA-1. SHA-1 is no longer considered secure for digital signatures, and RFC 8551 requires S/MIME
agents to support SHA-256. Pass DigestAlgorithm.Sha1 explicitly to restore the previous behavior.DigestAlgorithmRank, EnabledDigestAlgorithms, and the
Enable (DigestAlgorithm), Disable (DigestAlgorithm) and IsEnabled (DigestAlgorithm) methods) from
CryptographyContext and ICryptographyContext to OpenPgpContext. They were never used by S/MIME,
where the caller always chooses the signing digest algorithm, so on a SecureMimeContext they reported
a misleading SHA-1-only list. In OpenPGP they only determine the preferred hash algorithms advertised by
keys created with GnuPGContext.GenerateKeyPair (). The default OpenPGP ranking now matches GnuPG's
defaults for new keys: SHA-512, SHA-384, SHA-256, SHA-224 and SHA-1. Previously SHA-1 was ranked first.
RIPEMD-160 is no longer included by default.MimeReader no longer includes the newline sequence that precedes a multipart boundary marker in the
content passed to OnMimePartContentRead[Async] () and OnMultipartEpilogueRead[Async] (). Per
RFC 2046, that newline belongs to the boundary marker. Previously it was passed to the callback and then
excluded only from the endOffset reported to the corresponding End callback, so subclasses that
buffered the content had to trim it themselves. The bytes passed to the Read callbacks now match the
range between the Begin and End offsets exactly. Preamble content is unchanged.IDkimPublicKeyLocator and DkimPublicKeyLocatorBase with a new, more general
IDnsResolver interface. DkimVerifier and ArcVerifier now take an IDnsResolver, and the
protected DkimVerifierBase.PublicKeyLocator property has been replaced by DnsResolver.
DnsTxtResponse, along with a DnsQueryStatus that distinguishes a successful query, a
non-existent domain (NXDOMAIN) and a temporary failure. MimeKit now builds the
<selector>._domainkey.<domain> query name and parses the DKIM key records itself.v= tag
that is not first or not DKIM1, an unrecognized k= key type, or an s= tag that excludes
email are ignored. Keys whose h= tag does not permit the signature's hash algorithm or whose
key type does not match the signature algorithm are rejected, revoked keys (an empty p=) are
recognized, and the t=s flag is enforced for DKIM signatures.DkimVerifier.Verify[Async] () now returns a DkimSignatureValidationResult instead of a bool.
Status is one of Pass, Fail, Policy, TempError or PermError (matching the
RFC 8601 dkim method results), and the Reason property describes why a signature did not pass.
The result also exposes the signature's Domain, Selector, AgentOrUserIdentifier and
SignatureAlgorithm, and ToAuthenticationMethodResult () can be used to build an
Authentication-Results entry.FormatException; they are reported as
PermError and the FormatException is available via the result's Exception property. DNS
temporary failures (including exceptions thrown by the IDnsResolver) are reported as TempError.
Only argument errors and cancellation throw.x= expiration time has passed are now reported as PermError, and t=
timestamps beyond the year 2038 are now accepted.DkimVerifier.Verify[Async] (MimeMessage) overloads that verify every DKIM-Signature header
in a message, up to the new DkimVerifier.MaxSignatures limit (default: 10).DkimSigner now always writes the x= tag as an integer, even when SignaturesExpireAfter has a
fractional number of seconds.ArcVerifier.Verify[Async] () now provides diagnostics for ARC chain validation failures. As required
by RFC 8617, any error (including a DNS failure) still results in a Chain result of Fail, but:
ArcValidationErrors.DnsTemporaryFailure flag indicates that a public key could not be
retrieved due to a temporary DNS failure (or an exception thrown by the IDnsResolver), so that
receivers can choose to defer the message and try again later rather than seal it with cv=fail.ArcHeaderValidationResult has new Reason and Exception properties that describe why an
ARC-Message-Signature or ARC-Seal did not pass.HtmlTokenizerState.AttributeValueQuoted with separate AttributeValueDoubleQuoted and
AttributeValueSingleQuoted states, matching the HTML specification. This also changes the numeric
values of the HtmlTokenizerState members that follow them.MailboxAddress.Address setter no longer decode IDN-encoded (punycode) domains.
MailboxAddress.Address and Domain now return the domain exactly as it was parsed or set, so
user@xn--bcher-kva.example is no longer turned into user@bücher.example. Decoding was lossy (re-encoding
does not always reproduce the original A-label), platform-dependent (IdnMapping uses ICU or the Windows NLS
APIs), hid the A-label of a possible homograph domain, and caused FormatOptions.International to write an
ASCII domain as Unicode. Related changes:
MailboxAddress.GetAddress (false) now decodes the domain into its Unicode form instead of returning the
address as-is. Use Address to get the address as it was parsed or set.MailboxAddress.GetDomain (bool idnEncode) to get the domain in its IDN-encoded or Unicode form.MailboxAddress.IsInternational is now false for an IDN-encoded domain, and an address is serialized with
its domain as-is when FormatOptions.International is true.MailboxAddress.Equals () compares the addresses as-is, so an address with an IDN-encoded domain is no longer
equal to the same address with a Unicode domain. Compare GetAddress (true) to compare them regardless of form.MimeIterator.PathSpecifier now returns "1" (instead of "0") for a non-multipart top-level message body,
consistent with IMAP part specifiers and with the "N.1" already used for the non-multipart body of a
message/rfc822 part. MimeIterator.MoveTo () now expects "1" for such a body. A multipart that is the body
of a message (which has no IMAP part number) is still "0" (or "N.0").MimeMessage.MessageId, ResentMessageId and InReplyTo setters, the MimeEntity.ContentId
setter and the MessageIdList (MimeMessage.References) Add, AddRange, Insert and indexer
now share the same msg-id validation. The value may be specified with or without angle brackets, but an
ArgumentException is now thrown for values that previously would have been silently truncated or
altered: empty msg-ids (<>), anything other than whitespace or comments after the msg-id (such as a
second msg-id), unquoted whitespace in a msg-id without angle brackets, and line breaks (other than
folding whitespace) or NUL characters. Conversely, unusual msg-ids returned by the getters of a parsed message,
such as (paren@example.com, can now be assigned back to these setters.
MessageIdList.AddRange () now validates every item before adding any of them.<>) is now ignored when parsing: the msg-id getters (MessageId, ResentMessageId,
InReplyTo and ContentId) and MimeUtils.ParseMessageId () return null instead of an empty string,
and MimeMessage.References and MimeUtils.EnumerateReferences () skip it. Folding whitespace within a
quoted local-part is now unfolded.HtmlDocTypeToken.Name, PublicIdentifier and SystemIdentifier setters now throw an
ArgumentException for values that cannot be written as a well-formed DOCTYPE: an empty name, or a
name containing whitespace, > or NUL; or an identifier containing > or NUL, or containing both
' and ". HtmlDocTypeToken.WriteTo () no longer writes the identifiers when Name is null.MimeEntity.WriteTo (FormatOptions, Stream, bool, CancellationToken) and WriteToAsync () are no longer
virtual, and MimePart, Multipart and MessagePart no longer override them. The entity (and all of its
descendants) is now written by an internal writer that walks the tree without recursion. Subclasses that
overrode these methods to customize the output must instead customize the entity's headers or content.DmarcVerifier, which validates a message's author domain against its DMARC policy as defined
by RFC 9989 (DMARCbis). (issue #1180)
IDnsResolver interface, so no Public Suffix List is required. The walk is bounded to at most 8
queries per domain, and results are cached for the duration of each verification.adkim and aspf tags. Unrelated identifier domains never trigger DNS queries.DkimVerifier property) unless the caller
supplies existing DkimSignatureValidationResults, and only once a DMARC policy has been found.
DkimSignatureValidationResult has a public constructor for supplying existing results.SpfCheckResult, using the new SpfStatus enum.DmarcValidationResult exposes the DmarcStatus (None, Pass, Fail, TempError or
PermError), the policy to apply (after the sp=, np= and t=y rules), the requested policy,
the policy and Organizational Domains, the aligned DKIM and SPF results, and DmarcErrors
diagnostics. ToAuthenticationMethodResult () can be used to build an Authentication-Results entry.PermError.
Messages with multiple author domains are rejected by default; raising MaxAuthorDomains evaluates
each one and reports the most severe result.DmarcRecord for parsing DMARC policy records (DmarcRecord.Parse () and TryParse ()),
including the new RFC 9989 np=, psd= and t= tags. As required by RFC 9989, the parser is lenient:
invalid tag values are discarded in favor of their defaults and reported via DmarcRecordErrors rather
than causing the whole record to be rejected.MimeReader and MimeParser. Set ComplianceLogger
to an IMimeComplianceLogger implementation to receive MimeComplianceIssue diagnostics with
the violation, stream offset, line and column numbers, and MimeCompliancePositionKind.
Reporting does not change tolerant parsing or decoding.MimeComplianceSeverity and a set of
MimeComplianceCategories (Interoperability, DataLoss and Security). Severity is further
qualified by the MimeComplianceContext (Transport or Storage), since defects such as a bare
linefeed are far more serious in flight than at rest.Content-Id fields are checked per MIME part, not by comparing identifiers across parts.MimeComplianceOptions controls the reporting context, enables or disables individual address,
parameter, encoded-word and transfer-encoding validators, and caps reports with
MaxIssuesPerViolation. All validators are enabled by default; the default report cap is 0
(unlimited). A TooManyComplianceIssues diagnostic indicates when a cap has been reached.MimeAnalyzer sample that reports violations in a compiler-style
file:line:column: severity: message format.MimeKit.Tnef). This is a breaking change:
TnefReader and TnefPropertyReader were rewritten against [MS-OXTNEF] and [MS-OXCDATA] with
bounded allocations, async equivalents and resilient recovery from corrupt or truncated streams.TnefComplianceMode and TnefComplianceStatus were replaced by TnefOptions, ITnefComplianceLogger
and TnefComplianceViolation. There is no longer a strict mode that throws on the first violation.
TnefReader.ComplianceOptions (a TnefComplianceOptions) controls how violations are reported;
MaxIssuesPerViolation caps how many times each violation is reported per stream.TnefMessage object model (TnefAttachment, TnefRecipient, TnefMessageBody,
TnefPropertySet) loaded via TnefMessage.Load[Async] () or TnefPart.LoadTnefMessage[Async] ().TnefPart.ConvertToMessage () and TnefPart.ExtractAttachments () with
TnefMessage.ConvertToMime (), which follows [MS-OXCMAIL] (including PidTagMimeSkeleton,
PS_INTERNET_HEADERS and transport Received headers) and reports anything it could not
represent via TnefConversionResult.Losses.text/calendar part for appointments, meeting
requests, responses, counter-proposals and cancellations, following [MS-OXCICAL]. It covers time
zones, recurrence rules, deleted and modified occurrences, attendees and reminders. Per
[MS-OXCMAIL] 2.1.3.3.8 it is added as the last alternative of the body. Exception attachments it
consumes are not repeated as MIME attachments. You can turn it off with
TnefConversionOptions.GenerateCalendar. Data it cannot represent is reported as
TnefConversionLossKind.InvalidCalendarData or UnsupportedCalendarData.TnefConversionOptions.MaxCalendarExceptions (default 1024) and TnefConversionOptions.MaxCalendarExceptionsSize
(default 16 MiB) to bound the size of the generated text/calendar part for recurring appointments with many
exceptions. Exceptions beyond either limit are omitted and reported as
TnefConversionLossKind.CalendarExceptionLimitExceeded.TnefMessage.ConvertToMime () chooses the message body using the [MS-OXBBODY] best body algorithm
and never adds a text/rtf part. 4.x's TnefPart.ConvertToMessage () added every body (RTF, HTML
and plain text) as an alternative. When the best body is the compressed RTF body, the text/plain
and text/html alternatives are generated from it using RtfToText and RtfToHtml, as recommended
by [MS-OXCMAIL] 2.1.3.3.5. Otherwise an out-of-date RTF body is dropped.TnefMessage.ConvertToMime () matches the RTF \objattph attachment
placeholders with the attachments in PidTagRenderingPosition order ([MS-OXRTFEX] 2.2.3.4,
[MS-OXCMAIL] 2.1.3.4.1.1). Attachments that are browser-displayable images become inline,
Content-Id-referenced <img> elements in the generated HTML, grouped with the body in a
multipart/related. OLE attachments require explicit conversion to render inline. When the RTF encapsulates HTML,
the attachments that the extracted HTML references are inline and in the multipart/related,
following the HTML best body rules ([MS-OXCMAIL] 2.1.3.4.1.2).TnefConversionOptions.AttachmentPlaceholderCallback (TnefAttachmentPlaceholderCallback),
which can supply text, such as the attachment's file name, to insert at each attachment placeholder.TnefConversionOptions.OleObjectConverter and the abstract TnefOleObjectConverter class
(with Convert and ConvertAsync), which can render OLE object attachments as images
([MS-OXCMAIL] 2.1.3.4.4). OLE attachments that are not rendered are reported as a
TnefConversionLossKind.OleObjectNotRendered loss.TnefWriter and TnefPropertyWriter for producing [MS-OXTNEF] streams, including named
properties, multi-valued properties, recipient tables, embedded messages and [MS-OXRTFCP]
compressed RTF. TnefWriter.TemporaryStreamFactory allows attribute and property buffers to use
application-selected temporary streams instead of memory.attMessageClass and checksums are now validated; truncation is
reported as StreamTruncated; property, value and row counts are clamped to the attribute size;
embedded-message nesting is limited; and date, GUID and end-of-stream decoding errors can no longer
escape.PT_R4 and PT_DOUBLE are now decoded
little-endian, PT_SYSTIME as UTC and PT_CURRENCY scaled by 1/10000; the PT_I2 and
PT_BOOLEAN coercions and ReadTextValue were corrected; stream offsets were widened to 64 bits;
and the codepage is now selected per [MS-OXTNEF] 2.3.3.2, degrading gracefully when it is not
available.COMPSIZE/RAWSIZE, to stop at the end of
CONTENTS, to skip the CRC for uncompressed streams, and to discard unknown COMPTYPEs.Added standalone YEncReader and YEncWriter APIs for framed yEnc content, including individual
multipart ranges, streaming sync/async operations, metadata, configurable limits, and size/checksum
validation. They do not change MIME parsing or assemble multipart downloads.
Added MimeKit.Text.HtmlToText for converting HTML documents and fragments to plain text, with
support for paragraphs, headings, lists, blockquotes and preformatted whitespace. Link destinations
and image alt text are optional, and input, output and nesting limits are configurable.
Added MimeKit.Text.EnrichedToHtml for RFC 1896 text/enriched, supporting formatting, colors,
fonts, alignment, excerpts, language tags, document or fragment output, and resource limits.
The older text/richtext format is not supported.
Expanded MimeTypes mappings for modern document, image, audio, video, archive and data formats,
including WebAssembly, YAML, TOML, Zstandard, CBOR, GeoJSON, Parquet, Apache Arrow, SQLite,
HEIC/HEIF, JPEG XL, APNG, WebVTT and glTF. Corrected legacy names and reverse lookups; changed
preferred MIME types are listed under Breaking Changes.
Setting Subject, Date, Message-Id, In-Reply-To, MIME-Version, Importance, Priority or X-Priority through message properties removes duplicate occurrences, even when assigning a cached value. Updating Resent-Date or Resent-Message-Id continues to modify only the first occurrence, preserving older resent blocks.
MimeReader (and therefore MimeParser) no longer uses recursion to parse nested multipart and
message/rfc822 parts. Instead, it keeps an explicit stack of the entities being parsed, so a maliciously
deep nesting of MIME parts can no longer overflow the call stack (which terminates the process) when
ParserOptions.MaxMimeDepth is set to a large value. The sequence of callbacks is unchanged.
MimeMessage.WriteTo (), MimeEntity.WriteTo () (and their async counterparts) and MimeAnonymizer.Anonymize ()
no longer use recursion to write nested multipart and message/rfc822 parts, so writing a deeply nested message can
no longer overflow the call stack. The output is unchanged.
MimeMessage.Dispose () and MimeEntity.Dispose () no longer dispose nested entities recursively, so disposing a
deeply nested message can no longer overflow the call stack. An iterative, child-before-parent traversal uses
storage proportional to nesting depth. Dispose (bool) overrides now release only resources owned directly by
that object; MimeKit disposes structural children before invoking the override. All cleanup hooks are attempted
even if one fails; a single exception is rethrown, or multiple exceptions are reported in an AggregateException.
Retrying disposal of the root retries incomplete cleanup without repeating successful hooks. See the
porting guide for the subclassing contract.
Added MimeReader.OnMboxMarkerBeginAsync () and OnMboxMarkerEndAsync () so that every MimeReader
callback now has an asynchronous counterpart. The default implementations call the synchronous methods.
Added SmtpUtf8AddressValidator, which checks whether an address is a well-formed SMTPUTF8 mailbox
(RFC 5321 as extended by RFC 6531) that also follows the additional rules in
draft-ietf-mailmaint-smtputf8-syntax:
no A-labels, only PRECIS IdentifierClass code points (with the RFC 5892 contextual rules), Unicode
Normalization Form C, and at most one script per address (Han may be combined with Hiragana and Katakana,
with Hangul, or with Bopomofo). TryValidate () reports the reason through SmtpUtf8AddressError. The
validation tables use Unicode 18.0.0.
SmtpUtf8AddressValidationOptions.DecodeIdn decodes IDN-encoded (xn--) domain labels
and then validates the Unicode form. AsciiIsLatin counts ASCII letters as Latin, checking the
local-part and each domain label separately, so that homographs such as paypal@рaypal.com (with a
Cyrillic р) are detected. EnforceLengthLimits enforces the RFC 5321 length limits (64-octet local-part,
63-octet labels and 253-octet domain in A-label form, 254-octet address), reporting each through its own error.
Added SmtpAddressValidator, which checks whether an address is a well-formed RFC 5321 mailbox that can be
used in the MAIL FROM and RCPT TO commands without the SMTPUTF8 extension. TryValidate () reports
the reason through SmtpAddressError; addresses that are only invalid because they contain non-ASCII
characters are reported as NonAscii. IDN-encoded domains are accepted.
SmtpAddressValidationOptions.AllowIso2022JpLocalPart permits
ISO-2022-JP escape sequences within a quoted-string local-part (as used by some Japanese mail systems), and
EnforceLengthLimits enforces the RFC 5321 length limits.
Added the RtfToText and RtfToHtml text converters for text/rtf content (such as the
PR_RTF_COMPRESSED body of TNEF attachments). RtfToHtml extracts the original HTML from RTF that
encapsulates HTML ([MS-OXRTFEX]) unless ExtractEncapsulatedHtml is false, and otherwise renders the
RTF as HTML. Both converters are designed for untrusted input: their MaxFontTableEntries,
MaxColorTableEntries and MaxGroupDepth properties (4096 by default) bound the resources used by
hostile documents, nested groups that do not change any formatting are folded so that arbitrarily deep
nesting uses constant memory, \binN data is skipped without buffering, and RtfToHtml only renders
http, https, mailto, ftp and tel hyperlinks. The extracted HTML is filtered by the same logic as
HtmlToHtml: RtfToHtml.HtmlTagCallback is applied to it, RtfToHtml.MaxElementDepth limits its element
nesting (see HtmlToHtml.MaxElementDepth below), and RtfToHtml.NoScriptHandling controls how <noscript>
elements are handled (see HtmlToHtml.NoScriptHandling below). RtfToHtml.AttachmentPlaceholderCallback and
RtfToText.AttachmentPlaceholderCallback let the caller write content at each \objattph attachment
placeholder.
Added optional RTF compliance reporting through IRtfComplianceLogger, configured on RtfToText
and RtfToHtml. Diagnostics cover malformed syntax, unbalanced groups, undefined fonts and resource
limits, with byte offsets, line and column numbers, and group depth. RtfComplianceOptions supports
per-violation report caps.
Added optional HTML compliance reporting through IHtmlComplianceLogger, configured on
HtmlTokenizer and HtmlToHtml. Diagnostics cover tokenizer errors, ignored tags, foreign-content
transitions and depth limits, with character offsets and line and column numbers.
HtmlComplianceOptions supports per-violation report caps. Reporting does not change the output.
Added HtmlTokenizer.ScriptingEnabled, which corresponds to the HTML5 scripting flag and controls whether
<noscript> content is tokenized as raw text (true, the previous behavior) or as normal
markup (false, the new default). Set it to true to retain the previous tokenization behavior.
HTML text previews now interpret <noscript> content as markup rather than displaying its literal tags.
Added HtmlToHtml.NoScriptHandling. Previously, <noscript> content was always treated as raw text and was
never passed to the HtmlToHtml.HtmlTagCallback, so markup such as tracking images inside <noscript>
elements bypassed any filtering when the output was rendered with scripting disabled (as is typical for email).
The new default, HtmlNoScriptHandling.Unwrap, tokenizes <noscript> content as normal markup (so that it is
passed to the callback) and removes the <noscript> tags themselves, producing output that is interpreted the
same way regardless of whether the renderer has scripting enabled. See the HtmlToHtml.NoScriptHandling
documentation for the security implications of each setting.
Added ParserOptions.MaxHeaderLength to limit how much memory the parser will use to buffer any
single header. A header whose raw length exceeds the limit causes the parser to throw a FormatException.
The default limit is 16 KB.
Added HtmlTokenizer.MaxElementDepth and HtmlToHtml.MaxElementDepth to bound element tracking
(default: 4096). Consecutive identical elements count once. When the limit is exceeded, the remaining
input is returned as literal character data, which HtmlToHtml escapes rather than emitting as markup.
Added HtmlToHtml.OutputHtmlFragment, which removes the <!DOCTYPE>, <html>, <head> (including its
content) and <body> tags so that the output can be embedded within another HTML document. Like browsers,
it treats the <head> element as implicitly closed at the first start tag or non-whitespace text that does
not belong in the <head>, so content that browsers would render is not removed.
SqliteCertificateDatabase (and therefore DefaultSecureMimeContext) now falls back to
Microsoft.Data.Sqlite on .NET 8 and later if neither System.Data.SQLite nor Mono.Data.Sqlite
is usable. Previously, they were unavailable on platforms for which System.Data.SQLite does not ship
a native library, such as macOS on Apple Silicon (arm64). Connection pooling is disabled for
Microsoft.Data.Sqlite connections, as with the other SQLite bindings, so that the database file is not
left open (and locked on Windows) after the database is disposed.
Added MimeIterator.SkipChildren (), which makes the next MoveNext () skip the descendants of the current
entity (for example, the content of an attached message).
Added MimeIterator.Index (the index of the current entity within its parent multipart),
MimeIterator.CurrentMessage (the top-level or attached message that contains the current entity) and
MimeIterator.GetAncestor (int generation).
MimeIterator can now be used in a foreach statement. Since the iterator itself is enumerated, its
members (such as SkipChildren () and PathSpecifier) can be used within the loop.
Added MimeMessage.TryGetEntity (string pathSpecifier, out MimeEntity entity) (and to IMimeMessage), which
gets the entity at the specified MimeIterator path specifier (e.g. "3.2").
Base64Decoder
uses MimeKit's own SSSE3, AVX2 and Arm64 AdvSimd kernels while preserving permissive decoding.
EnableHardwareAcceleration is enabled by default on .NET 8 and later; it was disabled in 4.18.1
because of bugs in the runtime's Base64 decoder.UUEncoder and UUDecoder, with scalar fallback
for malformed input. Both expose an EnableHardwareAcceleration property.MimeIterator.MoveTo () now navigates directly to the specified entity in time proportional to its depth,
rather than walking the tree from the beginning (or from the current position). MimeIterator also no longer
allocates for each level it descends into.MimeMessage.BodyParts and Attachments now walk the MIME tree with MimeIterator instead of nested
iterators, so each step no longer costs time and stack space proportional to the nesting depth.MimeReader and MimeParser now index ancestor multipart boundaries for deeply nested messages
instead of walking the boundary stack for every candidate line. Ancestor lookup is logarithmic
in nesting depth, with no per-lookup allocations; shallow nesting retains a bounded linear path.MimeReader content scanning with SIMD on .NET 8 and later when compliance reporting
is disabled, including skipping CR detection in newline-free vector blocks.HtmlToHtml and HtmlTextPreviewer.
Bulk scanning and allocation reductions also improve ordinary HTML processing: compared with
4.18.1, the benchmarked documents tokenize about 15-25% faster with 34-39% fewer allocations;
HtmlToHtml uses 25-52% fewer allocations and is about 7-20% faster with TextWriter output.In this comparison, the 5.0 MimeParser was faster than 4.18.1 on 21 of 23 workloads with
compliance reporting disabled in both runs, and on 10 or 11 of 23 with all compliance validators
enabled, depending on the run. Compliance reporting is not free: dense quoted-printable
content, LF-only messages, and some header-heavy workloads still cost more to validate than
4.18.1 costs to parse without validation.
These are pre-release measurements from November 4, 2026, comparing the published MimeKit 4.18.1
NuGet binary with the 5.0 working tree based on commit be783d00, including fused content
validation and quoted-printable boundary-recovery and LF-line optimizations. Both used their
.NET 10 builds on .NET 10.0.14, Windows x64, with an Intel Core Ultra 7 268V processor.
persistent: true; 5.0 used
MimeContentStorage.Source. Both reference content in the seekable input stream rather than
copying it. These results do not represent the default Memory storage mode.MaxIssuesPerViolation = 1, and a counting logger.
Validation and logger callbacks are included; formatting, retaining, or writing diagnostics
is not. Compliance off means ComplianceLogger = null.Throughput is in MiB/s (higher is better). Each value is the arithmetic mean of the two runs'
median throughputs, rounded to the nearest MiB/s. The MimeReader columns measure scanning and
optional validation only: unlike MimeParser, the reader does not construct a MIME object tree.
Absolute throughput varied between runs; comparisons with older benchmark sessions should not
be used to isolate the effect of an individual optimization.
| Workload | 4.18.1 parser | 5.0 parser, off | 5.0 parser, on | 5.0 reader, off | 5.0 reader, on |
|---|---|---|---|---|---|
| Short message | 167 | 202 | 175 | 306 | 253 |
| Header stress | 365 | 516 | 328 | 717 | 410 |
| UTF-8 headers | 511 | 1,206 | 887 | 1,616 | 1,104 |
| Star Trek | 4,097 | 7,939 | 5,931 | 9,769 | 6,881 |
| 7bit body, 64 KiB | 6,330 | 10,404 | 7,279 | 11,819 | 8,119 |
| Base64 body, 64 KiB | 7,590 | 13,032 | 9,263 | 14,892 | 10,118 |
| Literal QP body, 64 KiB | 7,562 | 12,802 | 8,749 | 14,823 | 9,834 |
| 32-character lines | 4,490 | 11,438 | 7,295 | 12,420 | 7,726 |
| 998-character lines | 19,525 | 16,136 | 11,657 | 17,711 | 12,544 |
| QP, occasional escapes | 7,456 | 14,051 | 8,093 | 15,515 | 8,628 |
| QP, dense UTF-8 escapes | 7,106 | 13,640 | 803 | 14,968 | 815 |
| UUencoded body, full lines | 6,661 | 11,605 | 8,036 | 11,863 | 7,856 |
| Attachments, CRLF | 6,292 | 10,284 | 7,106 | 10,839 | 7,367 |
| Attachments, LF | 6,195 | 10,161 | 2,562 | 10,775 | 2,613 |
| Dash-heavy content | 3,396 | 3,232 | 2,855 | 3,353 | 2,864 |
| Enron | 478 | 621 | 427 | 859 | 543 |
| Forwarded messages | 773 | 889 | 700 | 1,356 | 990 |
| Modern headers | 1,187 | 1,584 | 1,117 | 2,134 | 1,447 |
| Newsletters, CRLF | 3,618 | 4,753 | 2,182 | 5,169 | 2,375 |
| Newsletters, LF | 3,235 | 4,406 | 999 | 4,995 | 1,032 |
| Large plain text | 5,571 | 9,316 | 6,499 | 9,457 | 6,540 |
| Test suite, CRLF | 271 | 300 | 229 | 470 | 326 |
| Test suite, LF | 204 | 231 | 167 | 366 | 235 |
Only inputs accepted by both versions were timed: 3,300 fixture entries across the workloads. Four entries were excluded from both sides: two Enron messages that exceeded 5.0's default header-length limit of 16K, and one malformed message in each test-suite newline variant. Accepted inputs included 115 cross-version serialization differences; the comparison does not imply identical behavior between releases. Within 5.0, enabling compliance reporting did not change serialized output. Results depend on message structure, encoding, newline format, hardware, runtime, and storage mode; the workload counts above are not an aggregate speedup or a guarantee for other inputs.
message/rfc822
parts followed by multipart or mbox delimiters. Empty entities now have consistent offsets and
line counts, and CRLF sequences split across reads are recognized correctly.InvalidCastException in the reader-based
parser (previously ExperimentalMimeParser).MimeParser,
including trailing boundary markers and missing final newlines. Use FormatOptions.EnsureNewLine
when the output must end with a newline.FormatOptions.VerifyingSignature is set.=? prefixes split across internal word boundaries no longer corrupt display names
when serialized and parsed again.=? text, and RFC 2047-encoded UTF-8.
Loose parsing of unquoted values now preserves the last character, trims trailing whitespace
correctly, and ignores following comments. Literal parentheses must be quoted or encoded.Received.Id validation and unfolding of ReceivedClause.Comments, and recovery of invalid
quoted Content-Disposition values.AuthenticationResults parsing with buffer offsets, empty values, dotted method names,
Office 365-style headers and escaped comments. Serialization now quotes authserv-ids and property
values as needed and preserves whitespace-containing values when folding.ArgumentOutOfRangeException rather than overflow
when the result cannot be represented as an int.FilteredStream reads to flush filters at end of input and avoid reporting end-of-stream
prematurely when a filter buffers an entire chunk.CharsetFilter to flush buffered decoder state even when the final input buffer is empty,
preserving replacement characters and reporting strict decoding errors for truncated input.Dos2UnixFilter, split-CRLF line lengths and
unterminated From line detection in BestEncodingFilter, and chunk-dependent offsets and
exceptions in OpenPgpDetectionFilter.RtfCompressedToRtf.IsValidCrc32 incorrectly accepting truncated headers and
RtfCompressedToRtf.Reset() retaining dictionary bytes from the previous stream.HtmlToHtml.HtmlTagCallback or created accidentally when filtered output was parsed again.HtmlToHtml and HtmlTextPreviewer handle
the corresponding content suppression and element closures consistently.
HtmlToHtml also drops ignored frameset start tags after the outermost frameset closes,
preventing them from taking effect when earlier frameset markup is removed.< characters
adjacent to removed markup.TextToHtml and FlowedToHtml, including culture-independent matching,
balanced delimiters, IPv6 hosts, address literals, IDNA domains, query strings and fragments.
Whitespace, control characters and invisible formatting characters no longer disguise link
targets; bounded scanning also avoids excessive work on malformed addresses.TextToFlowed space-stuffing and long-word wrapping, and excessive output growth at deep
quote depths. TextToHtml and FlowedToHtml now honor callback suppression of blockquote end tags
and nested content.OpenPgpContext.Verify[Async] () now throws FormatException, rather than InvalidCastException,
for non-signature packets in signature data.WindowsSecureMimeContext to import signer certificates regardless of whether S/MIME
capabilities are present, and to retain advertised capabilities for selecting reply encryption.SqliteCertificateDatabase validates constructor arguments before creating the database file.Your coding agent can read these notes before it upgrades. Set up the MCP server →
Bumped System.Security.Cryptography.Pkcs to 10.0.13
Prevent integer overflows in TnefPropertyReader due to corrupt content.
Removed base, embed, input, link and source tags as "unsafe" tags. These are all void tags in HTML, meaning they do not have inner content. (issue #12
Note: As of BouncyCastle 2.7.0, decrypting S/MIME content encrypted with Blowfish, CAST5, RC2/40, RC2/64,
or RC2/128 will fail with a CmsException: no fixed size for content-encryption key; constant-time RSA unwrap unavailable.
Use the following code snippet to restore pre-2.7.0 behavior:
Org.BouncyCastle.Utilities.Properties.SetThreadBoolean (Org.BouncyCastle.Utilities.Properties.CmsAllowLenientRsaPkcs1, true);
…to protect against Cross-Size Scripting (XSS) vulnerabilities.
Simplified logic for illegal ctrl characters within quoted-string local-part tokens in addr-specs.
[SECURITY] Use stricter parsing logic for quoted-strings in addr-specs to prevent SMTP command injection attacks when those quoted-strings include CRL
Fixed inexact read in TnefPropertyReader.GetEmbeddedMessageReader().
Updated BouncyCastle.Cryptography dependency to v2.6.1.
Fixed a memory leak in MimeAnonymizer and MimeUtils.Unquote() which gets used by the address parser. (issue #1161)
Removed CTRL characters from the list of allowed domain characters.
Fixed logic for validating HTML Tag and Attribute names. (issue #1136)
Fixed logic for converting BouncyCastle DSA keys to System.Security equivalents.
Started adding some DynamicallyAccessedMembers attributes for AOT compatibility.
Added TypeConverters for InternetAddress and InternetAddressList.
Bumped System.Formats.Asn1 to v8.0.1 to fix a denial of service security issue.
Bumped BouncyCastle.Cryptography from 2.3.1 to 2.4.0
Fixed hex format specifier for PGP keyserver lookup. (issue #1028)
Fixed MailboxAddress to not use punycode to encode or decode the local-part of an addr-spec. (issue #1012)
Improved folding logic for Disposition-Notification-Options header values. (issue #979)
Added work-around for broken Message-ID header values of the form <id@@domain>. (issue #962)
Follow the spec more closely for allowable header field characters. (issue #936)
List<string>s in DomainList.ctor(), lazily allocate the
list only when a domain is added. Another minor reduction in GC pressure.Readded the System.Net.Mail-to-MimeKit conversion APIs for the netstandard2.x frameworks. (issue #913)
Ported to BouncyCastle v2.1.1. (issue #865)
Improved the UrlScanner to allow numeric key/value pairs (seems to match behavior in other url detection algorithms).
Added the .msg <-> application/vnd.ms-outlook mime-type mapping. (issue #880)
startIndex and count arguments.https://example.com?query
(issue #897)Fixed potential NRE's in the GnuPG config parser
Fixed a variety of memory leaks revealed by (issue #852)
Fixed MessageDeliveryStatus.ParseStatusGroups() to catch FormatException instead of ParseException. (issue #837)
Improved logic for reformatting headers when MimeMessage.WriteTo() is called with FormatOptions.International set to true.
Introduced a new IPunycode interface and Punycode class allowing developers to override the default implementation that uses .NET's IdnMapping class.
Added Import() methods for X509Certificate2 for all S/MIME contexts. (issue #784)
Special thanks to Fedir Klymenko for his improvements to MemoryBlockStream and SecureMimeContext.Compress!
Rewrote QuotedPrintableEncoder to more strictly fold at the specified line length. (issue #781)
Special Thanks to Jason Nelson for taking the lead on many of the listed (and unlisted) performance improvements and helping me make MimeKit even more awesome!
When initializing character encodings for netstandard and net50/net60, wrap the Reflection logic to invoke System.Text.Encoding.RegisterProvider() in
message/delivery-status parts where all status groups after
the first are base64 encoded. This seems to be a bug in Office365 where it treats the first
status group as MIME entity and the following status groups as the content.
(issue #250)Always use a lowercase domain name in the Message-Id to work around bugs in eM Client. (issue #734)
Removed APIs marked as \[Obsolete\] in 2.x.
Nothing published for this version
Improved MimeParser to be a little more efficient based on work being done for the upcoming v3.0 release.
Use DebugType=full for .NET Framework v4.x. (MailKit issue #1239)
Allow ..'s and trailing .'s in the local-part of an addr-spec by introducing a new RfcComplianceMode.Looser enum value that can be set on the ParserOp
Added a way to force MimeKit to always quote parameter values. (issue #674)
Fixed S/MIME support using WindowsSecureMimeContext with MimeKit's CmsSigner classes which was causing a PlatformNotSupportedException. (issue #664)
Fixed DSA key conversion logic to work more reliably.
Treat message/disposition-notification and message/delivery-status the same as text/* when preparing for signing. (issue #626)
Added SQL Server support. (issue #619)
Include WindowsSecureMimeContext in the .NET Standard 2.x build. (issue #600)
Refactored OpenPgpContext to separate out key storage implementation. (issue #576)
Nothing published for this version
Improved logic for verifying signatures for MimeParts containing mixed line endings. (issue #569)
Fixed InternetAddressList.Insert() to allow inserting at the end of the list. (issue #559)
Fixed the MimeEntity.ContentId setter to use ParseUtils.TryParseMsgId() instead of MailboxAddress.TryParse() so that it is more lenient in what it acc
Updated net46, net47, and net48 builds to reference Portable.BouncyCastle instead of the standard BouncyCastle package, just like the netstandard buil
;.Fixed parsing of email addresses containing unicode or other types of 8-bit text. (issue #536)
Fixed message reserialization after prepending headers. (issue #524)
"[" and "]"
characters in the display-name.
(issue #532)Don't use PublicSign on non-Windows NT machines when building. (issue #516)
Added the text/csv mime-type to the MimeTypes mapping table for files with a .csv extension.
text/csv mime-type to the MimeTypes mapping table for files with a .csv extension.message/global-delivery-status, message/global-disposition-notification,
and message/global-headers to MimeParser.
(issue #514)Fixed reserialization of message/rfc822 parts to not add an extra new-line sequence to the end of the message. (issue #510)
Updated CmsSigner's default DigestAlgorithm to Sha256 instead of Sha1 to match System.Security.Cryptography.Pkcs.CmsSigner's default.
Fixed MultipartRelated to fall back to the multipart/related type parameter when locating the Root. (issue #489)
Added AuthenticationResults class for parsing and constructing Authentication-Results and ARC-Authentication-Results headers.
One column per quarter.