postal-mime is a robust and zero-dependency JavaScript library designed for parsing raw email messages in RFC822 format into a structured object. It operates effectively across Node.js, browser environments (including Web Workers), and serverless platforms like Cloudflare Email Workers. The library is currently stable at version 2.7.4, with a recent release cadence suggesting active maintenance and bug fixes, typically every few weeks or months. Key differentiators include its full TypeScript support, comprehensive handling of complex MIME structures (multipart messages, nested parts, attachments), built-in security limits to prevent Denial-of-Service attacks from malformed emails, and strict adherence to RFC 2822/5322 email standards. It differentiates itself by offering broad environment compatibility without external dependencies, making it a lightweight and versatile choice for email processing.
npm install postal-mimeVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a basic email string with subject and HTML content, applying options, and logging the structured output using TypeScript in a Node.js environment.
Upgrade to `postal-mime@2.6.1` or later to include critical security patches. Ensure your environment uses the latest patched version.
Upgrade to `postal-mime@2.7.2` or newer, which includes explicit null checks. Alternatively, implement defensive coding by checking for `null` before accessing nested properties, e.g., `email.contentDisposition?.parsed?.parameters`.
For CommonJS usage, ensure you are on `postal-mime@2.7.4` or newer. If issues persist, verify your bundler's configuration for handling dual-package exports or prefer ESM imports where possible.
Always use the latest stable version of `postal-mime` for the most accurate and comprehensive TypeScript definitions. Review your code after upgrading to catch any new type errors that might reveal underlying logic issues due to previously incorrect typings.
Configure your bundler (e.g., Webpack, Rollup, Parcel) to alias `postal-mime` to its browser-specific path or ensure the relative path from your application entry point to `node_modules` is correct. For Web Workers, ensure the path resolution is handled correctly.
Upgrade to `postal-mime@2.7.2` or newer. If not upgrading, defensively check for `null` or `undefined` before access, e.g., `email.contentType?.parsed?.parameters`.
For ESM, ensure `import PostalMime from 'postal-mime';`. For CJS, use `const PostalMime = require('postal-mime');`. For browser environments, use the specific path `import PostalMime from './node_modules/postal-mime/src/postal-mime.js';`. Ensure you are on `v2.7.4` or later for best CJS compatibility.Upgrade to the latest version of `postal-mime` to benefit from updated and corrected TypeScript typings (e.g., `2.7.3`, `2.6.1`). Review your code for type assertions that might be masking actual type issues.
No dependency data recorded yet.