npm / mailparser
mailparser
What changed in mailparser 3, from its official release notes, upgrade guides and advisories. Also covers @types/mailparser. Sources checked 2026-11-30.
2 breaking4 security6 new APIs and options1 performance18 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmailparser 331 changes
Breaking changes 2
Schemaless hosts with a port are no longer linked.
Comments are dropped from Content-Type and Content-Disposition entries in the headers map.
Security 4
Bounds scanning of untrusted text bodies.
Prevents RFC 2047 encoded words from fabricating addresses during address decoding.
mailparser vulnerable to Cross-site Scripting
URLs and link text are now escaped to prevent XSS.
New APIs and options 6
Exports parseOtpToken so OTP-Token values can be read outside the parser.
The simpleParser result and MailParser instance expose the one-time passcode as otp: { code, origin } when the message has exactly one valid OTP-Token header.
parseAddressHeader() accepts decodePunycode: false to keep IDN domains in ASCII form.
Accepts false to skip hashing attachments.
Exported for parsing an address header value.
The package now provides ES module and CommonJS builds after migrating to TypeScript.
Performance 1
Builds the HTML and text forms only when they are read, avoiding unnecessary work.
Fixes and other changes 18
Closing quotes and guillemets after a URL are no longer included in the generated link.
URLs with bracketed IPv6 hosts are now linked.
A mailto link in a text body links the address rather than including the href attribute name.
RFC 2231 parameters are distinguished using what libmime decoded, rather than a second scan of the header.
The lazily built html and text forms can be assigned again.
Text bodies are decoded with libmime's decode stream.
A decoded display name is no longer turned into an address.
The message is kept when its HTML cannot be converted to text.
An unavailable checksum algorithm is reported as a parser error.
Honours backpressure when handling attachments.
Caps inlined CID images.
Reports errors from the splitter that occur late.
Derives partId from the part number.
Ensures settlement happens only once.
Declares the Node 20 minimum requirement that the package already had, helping developers identify the required runtime.
Decode iso-8859-8-i and iso-8859-8-e charsets as iso-8859-8.
False values are filtered from empty References headers.
Parsing of unquoted commas in display names is fixed, so addresses with those display names can be parsed correctly.